I have index.php and use jQuery .load() to load content from load.php.
When I trigger an event on elements that are in the index.php, the event fires. On the same elemen
Using click
will create an event listener on the element at the time it is called. if the element does not exist at the time click
is called the listener is not created. You need to use event delegation using on
(or delegate
in older versions of jquery).
Have a look at the on documentation and read about delegation. You'll need something like this:
$("<selector of static ancestor>").on("click", "#clickme" , function(){})
The click
event binder does not bind to any elements created after execution. You can add a click
listener immediately following the .load()
method, or you can use something like live
or delegate
to bind to element patterns in the DOM.