$(\'div.myclass\').live(\'click\',function() {
alert(\'i should respond only once\');
});
I know that there is a one() function wi
$('div.myclass').live('click',function() {
if($(this).attr('clicked') != 'yes')
{
alert('i should respond only once');
$(this).attr('clicked', 'yes');
}
});
In the live() click handler, you can bind() an event directly on the element which calls e.stopPropagation(). So on the next click, the event won't be able to bubble up to the document, where it actually triggers the live event.
Demo: http://jsfiddle.net/kKHJm/
$('li').live('click',function(){
$(this).click(function(e){
e.stopPropagation();
});
// Do stuff once here
});