问题
i am trying to run a live click function in jQuery and found that's not work like
$(function () {
$("#elem #check").click(function () {
alert('goaa');
});
$("#elem #check").live("click", function () {
alert('fo');
});
});
the page load and nothing come from ajax.when i trying to run that i found that [click] first is work and second not [live click].
what is the reason of click are work and live not worked.:-
Well it is my fault that i am trying to run it on jQuery UI tab so that's not worked.
回答1:
No idea what the problem is. As you can see in the following live demonstration this code works perfectly fine.
回答2:
probably somewhere for your selector or on parent elements click event stopped
for ex $("#elem")
or on parent
$("#check").live("click", function (event) {
event.stopPropagiation();
});
in oter place stopped event bubbling and capture
回答3:
Earlier, live function works perfectly in a dynamic loaded content. But it is not working on recent JQuery file. But you can use another function: https://api.jquery.com/delegate/
来源:https://stackoverflow.com/questions/4913636/jquery-click-function-work-but-live-click-not-work