Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery - trigger('change') vs change()

Tags:

jquery

Edit: To clarify, what I want to ask is: In what scenario will you prefer one over another? (maybe an advantage on either one of the syntax?)

What is the difference between:

.trigger('change') and .change()

Both works as expected. Is there any cases where both will behave differently?

like image 738
zhuhang.jasper Avatar asked May 10 '16 06:05

zhuhang.jasper


1 Answers

The JQuery documentation for .change() says:

This method is a shortcut for .on( "change", handler ) in the first two variations, and .trigger( "change" ) in the third.

like image 154
Rahul Tripathi Avatar answered Oct 02 '22 13:10

Rahul Tripathi