Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialnathanielcusano
9,808 PointsWhich of the following is NOT a potential method for attaching event handlers to DOM elements?
I can't understand the documentation on the trigger() method in simple terms.
1 Answer
Michael Braga
Full Stack JavaScript Techdegree Graduate 24,174 PointsThe tirgger() method does not attach event handlers to DOM elements. Instead, as its name suggests, triggers event handlers from other places in your code manually. For example, if you have a click event for button 1 you can trigger that click event from any other place in your code with $( "button:first" ).trigger( "click" );
The jQuery API Doc has a good example if you scroll to the bottom:
http://api.jquery.com/trigger/
Also you can tell it is not a method for attaching event handlers because it does not accept a callback function as one of its parameters like we saw for .on() and .click().