This article illustrates the method that jquery implements to prevent the backspace bar from returning. Share to everyone for your reference. The implementation methods are as follows:
Copy Code code as follows:
Backspace not available in browser
$ (document). KeyDown (function (e) {
var keyevent;
if (e.keycode==8) {
var d=e.srcelement| | E.target;
if (d.tagname.touppercase () = = ' INPUT ' | | D.tagname.touppercase () = = ' TEXTAREA ') {
keyevent=d.readonly| | d.disabled;
}else{
Keyevent=true;
}
}else{
Keyevent=false;
}
if (keyevent) {
E.preventdefault ();
}
});
Only prevent backspace from being available in input and textarea browsers
$ (document). KeyDown (function (e) {
var keyevent;
if (e.keycode==8) {
var d=e.srcelement| | E.target;
if (d.tagname.touppercase () = = ' INPUT ' | | D.tagname.touppercase () = = ' TEXTAREA ') {
keyevent=d.readonly| | d.disabled;
}
} else{
Keyevent=false;
}
if (keyevent) {
E.preventdefault ();
}
});
I hope this article will help you with your jquery programming.