I have several HTML elements, that are rendered by a javascript function on the page:
<a href="#" class="test1">Test</a>
<a href="#" class="test2">Test</a>
<a href="#" class="test3">Test</a>
I then have further javascript that I use to create a function when Test is clicked:
$(document).ready(function(){
$( ".test1" ).click(function() {
// Code here
});
$( ".test2" ).click(function() {
// Different code here
});
$( ".test3" ).click(function() {
// Different code here
});
});
However, because the HTML inserted is not loaded at the same time the page loads (it is dynamically inserted after), my click function doesn't capture the event. How can I solve this?