I have an element with a set of events like
<input type="text" id="txt" onkeyup="javascript: alert('keyup');" />
Now I want to intercept this event and run another script in addition to the default. I wrote the following code:
jQuery(document).ready(function(){ var old = $("#txt").keyup; $("#txt") .unbind('keyup') .attr('onkeyup', '') .each(function() { this.onkeyup = null; }); $("#txt").keyup(function(event){ alert("before old call");
But it does not work as I expected. Does anyone know how to make this work?
Link to fiddle: http://jsfiddle.net/p5JeA/
What if the keyup event for input is not enabled but set using jQuery bind? I want to override / extend the default behavior, I don't want to change the base code.
Peter source share