I want to check the brows开发者_StackOverflow社区er width, and if it's more than 850, to fade in a div.
Then whenever the browser is resized, I want to fade out that div if the browser width is less than 850, and fade it in again if the browser width is more than 850.
Thank you in advance for helping out with this!
Dimitri Vorontzov
As far as I know, you can use the $(window).width()
(doc) to get the browser's width. Use the resize
event to handle the changes in browser size. (doc)
The resize event is sent to the window element when the size of the browser window changes:
$(window).resize(function() {
if ($(window).width() > 850) {
// do something
} else {
// do something else
}
});
精彩评论