jQuery Event Handler
Last Updated Jul 21, 2015, 12:00:06 PM
jQuery delegate() Method
jQuery delegate()
method is used to attach a handler to one or more events for all matched elements.
As of jQuery 1.7, delegate()
method has been substituted by the .on() method. Earlier version the most effective way to use the event was delegation.
Here is an example to use jquery delegate() method
ExampleIn the above example, what jquery delegate()
method does is , everytime you click on the html body
content, it will add another paragraph which contains text "Added another element"
Try It Now
jQuery on() Method
jQuery on()
event method is used to attach one or more handler to the matched elements in the DOM tree.
jQuery on()
method attaches event handlers to the set of selected elements in the jQuery object. As of jQuery 1.7, the jquery on()
method provides all functionality required for attaching event handlers.
The above example jquery on()
method , everytime you click on the body element it will add another paragraph element with count
Try It Now
Other Advanced jQuery Events you might want to learn
jQuery Complete Events Reference
jQuery Events
jQuery Document Events
jQuery Keyboard Events
jQuery Mouse Events
Sources and Credits
The content and methods in the tutorial has been referred and updated with jQuery API and The jQuery Foundation
Last Updated Jul 21, 2015, 12:00:06 PM
Learning 200 jQuery Functions with 800 Examples -Udemy
Learn jQuery in One Month - from OneMonth
The Ultimate Web Development Course -Udemy
Learn jQuery: An In-depth Course For Beginners -Udemy