$(window).bind('resize')
and $(window).resize()
?bind
nested over resize
. What impact does it have? See code below..resize()
works on elements as well as window. Does bind
work in similar way too...
like $('#el').bind('resize', function (event) { // stuff });
?JS:
$(window).bind('resize', function (event) {
$(window).resize(function () {
// do something here
});
});
From jQuery page .resize()
:
This method is a shortcut for .on('resize', handler).
and .on()
is:
The .on() method attaches event handlers to the currently selected set of elements in the jQuery object. As of jQuery 1.7, the .on() method provides all functionality required for attaching event handlers. For help in converting from older jQuery event methods, see .bind(), .delegate(), and .live().
So based on jQuery api description, I think there is no difference it's just a shortcut similar to $.click()
and others
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With