<input name="mybutton" type="button" class="agh" id="id_button" value="Dim" onClick="resetDims();">
In the above Input tag i have to remove the entire "Onclick=myfunction();" and its function for the input tag and write my functionality for this button when we "click"
$("#mybutton").onclick(function(){
//$("#mybutton").removeattr("onClick","");
})
If you need to remove the onclick attribute "on-demand" use
$('#id_button').removeAttr('onclick').click(function(){
});
Have a second look at the selector. You need to query the ID, your snippet
trys to select mybutton as ID, which infact is the name of the element.
You cannot use unbind to remove an inline model onclick handler. unbind will only work with jQuery-bound event handlers. It can be done like this:
document.getElementById("id_button").onclick = null;
// you can still get the element using the jQuery shorthand though
// the point is to get at the DOM element's onclick property
$("#id_button")[0].onclick = null;
Demo: http://jsfiddle.net/ax52z/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With