Livequery doesn't find element in a first look
I have a button that is generated dynamically and I want to get the click event in this button.
So, I coded this:
$(document).ready(function(){
$('#editDescription').livequery('click',function(){
alert('click');
});
});
But it did not work.
So, I try the following to see if the element is seen by the JS:
$(document).ready(function(){
$('body').livequery('click',function(){
console.log($('#editDescription'));
});
});
And it worked, the element was there. So I did that:
$(document).ready(function(){
$('body').livequery('clic开发者_如何学Ck',function(){
$('#editDescription').livequery('click',function(){
alert('click');
});
});
});
And after the second click, started to alert. Why this happens and what can I do to correct this?
Thanks!
精彩评论