I have a question about “event click” and “order of execution”.
I make a example here ( The HTML is generated by a external javascript ) :
HTML:
<a href="#" id="comments-replybutton" onclick="alert('Action');return false;">Comment</a>
JavaScript:
$(document).ready(function(){
$('#comments-replybutton').click(function(){
alert('2 attach event');
});
});
I want that when do click in “Comment” first execute the action of jquery (bind event).
Is this possible?
You mean, like this?
Edit after comment
You can also name your function to unbind:
Edit 2
I guess you can kill off the original event easily, just by saying document.getElementById(‘comments-replybutton’).onclick = “” or something similar. You can re-attach it by copying before:
A bit dirty, but I’m too lazy to look it up :S preventDefault won’t help you here, though.
http://jsfiddle.net/C37ka/