I have a page which declares some jQuery code and I cannot get it to trigger on HTML which has been loaded using AJAX.
I have created the following simple code to illustrate the problem. It is a very simple page containing a link with a class called "link". There is also a div which will contain an external HTML file which also contains another link with the same "link" class applied to it. The jQuery triggers on the "link" class and pops up an alert.
It works when you click on "Click parent link" but not when you click on "Click loaded link" even though both links have the same class.
<a class="link" href="#">Click parent link</a>
Here is the external link.htm file:
<a class="link" href="#">Click loaded link</a>
In the example given, the div loads on document ready, however it could equally load on some other event say clicking on a button or link.