Skip to content Skip to sidebar Skip to footer

Attaching Event To Future Elements Using Jquery

I am using jquery 1.8 and have to display popup when user clicks some area with class dropdown-toggle. I have attached the events using on while the page loads for the first time.

Solution 1:

You can use delegation with .on(). This way it will listen for a click in document (it could also be a parent of your element, as long as its present when the event handler is run), when fired look for the element specified as a parameter of the .on().

Try this:

$(document).on("click", '.dropdown-toggle', function (e) {

Post a Comment for "Attaching Event To Future Elements Using Jquery"