Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 860
Mohammadreza Esmaeeli Avatar asked Feb 27 '16 07:02

Mohammadreza Esmaeeli


1 Answers

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

like image 191
Harshad Avatar answered Sep 30 '22 15:09

Harshad