Possible Duplicate:
How can I remove the event handler once the click event has fired?
I am trying to assign click event to a button using live and want the user can only trigger it only once. Are there anyways to do it?
//I only want the alert show once and disable the click event...
$('#testBtn').live('click', function(){
alert('hey ya');
})
Please note: The button is created dynamically.
You can use
one()with delegated handlers as well (in jQuery 1.7+) and replace the deprecatedlive()function with something like this:replace
documentwith the closest non-dynamic parent.