Not sure if this is posible or not, but I’m trying to use JavaScript that I loaded via a script tag when the page was initially requested on dynamic HTML that was loaded via jQuery’s load() function.
Example: http://jsfiddle.net/3MR43/
As you can see in the example, after clicking a link in the pop up box, the link goes. The problem is that the link was suppose to be stopped, and you were suppose to see an alert.
However, if I paste the HTML that I am loading via jQuery, it works, so the code is fine.
Description
You need jQuery
.live()or.on()method to bind events to dynamically created html.Choose
.live()or.on()depending on the version of jQuery you are using.Check out my sample and this jsFiddle Demonstration
Sample
… for jQuery.live()
… for jQuery.on()
More Information