Difference between window.resize () and window.on ('resize') in jquery

What is the difference between window.resize() and window.on('resize' , function()) in jquery?

+5
source share
1 answer

From the jQuery page .resize ():

This method is a shortcut for .on ('resize', handler).

and .on ():

The .on () method attaches event handlers to the currently selected set of elements in the jQuery object. Starting with jQuery 1.7, the .on () method provides all the functionality needed to attach event handlers. For help converting from older jQuery event methods, see..bind (),. Delegate (), and .live ().

So, based on the jQuery api description, I think there is no difference, it is just a shortcut similar to $ .click () and others

+6
source

Source: https://habr.com/ru/post/1243999/


All Articles