Does anyone know how can I remove keypress from input with jquery?
Example:
<input type="text" keypress="cleanMsg()" id="cleanMsg" name="cleanMsg">
How can I removed the keypress="cleanMsg()" from input by using jquery? Or anyway to replace keypress="cleanMsg()" to keypress="Msg()"??
I assume you mean "how do you remove the 'keypress' attribute from the input", in which case this would work
<script>
$(document).ready(function(){
$("#cleanMsg").removeAttr("keypress");
});
</script>
If you want to bind to a keypress, you should do it in the jQuery way (refer to the docs), with this code the above attribute within the input tag is redundant
<script>
$(document).ready(function(){
$("#cleanMsg").keypress(function(){
//do something here
});
});
</script>
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