Cannot get jQuery click handler to fire on ajax loaded element
-
23-09-2019 - |
Question
"MyParentPage.htm" uses the load function of jquery to load('myDiv.htm') //
myDiv.htm only contains:
<a href="#" class="bt-cbox">Click me</a>
I have the following in "MyParentPage.htm"
$(document).ready(function() {
$(".bt-cbox").click(function() {
alert("handler hit");
});
});
Why is the my alert not being hit
Solution
$(document).ready(function() {
$(".bt-cbox").live("click",function() {
alert("handler hit");
});
});
See live
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow