Home Web Front-end JS Tutorial Using jquery to realize that pressing backspace in IE is equivalent to the return operation_jquery

Using jquery to realize that pressing backspace in IE is equivalent to the return operation_jquery

May 16, 2016 pm 04:55 PM
backspace ie return

In fact, disabling it does not mean disabling it completely. The back key defaults to clicking the back button in each browser. As long as it can still be used for normal text input, the backspace key in other situations will be disabled. Let’s look at the jquery implementation code:

Copy code The code is as follows:

$(function(){
function dokey(event){
var ele = event.target;
var eleName = ele.nodeName;
var flag = true;
if(eleName=="INPUT"|| eleName=="TEXTAREA"||eleName=="SELECT"){
var re = $(ele).attr("readonly");
if(re){
flag = true;
}else{
flag = false;
}
}
if(event.which==8&&flag){
event.preventDefault();
event.stopPropagation() ;
}
}
$(document).keypress(dokey).keydown(dokey);
});
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Which key is backspace? Which key is backspace? Mar 23, 2023 pm 01:52 PM

Which key is backspace?

What is the delete key on the keyboard? What is the delete key on the keyboard? Mar 16, 2023 pm 04:48 PM

What is the delete key on the keyboard?

PHP Tips: Quickly Implement Return to Previous Page Function PHP Tips: Quickly Implement Return to Previous Page Function Mar 09, 2024 am 08:21 AM

PHP Tips: Quickly Implement Return to Previous Page Function

What should I do if win11 cannot use ie11 browser? (win11 cannot use IE browser) What should I do if win11 cannot use ie11 browser? (win11 cannot use IE browser) Feb 10, 2024 am 10:30 AM

What should I do if win11 cannot use ie11 browser? (win11 cannot use IE browser)

Internet Explorer opens Edge: How to stop MS Edge redirection Internet Explorer opens Edge: How to stop MS Edge redirection Apr 14, 2023 pm 06:13 PM

Internet Explorer opens Edge: How to stop MS Edge redirection

What results does MySQL return after inserting data? What results does MySQL return after inserting data? Mar 01, 2024 am 10:27 AM

What results does MySQL return after inserting data?

How to cancel the automatic jump to Edge when opening IE in Win10_Solution to the automatic jump of IE browser page How to cancel the automatic jump to Edge when opening IE in Win10_Solution to the automatic jump of IE browser page Mar 20, 2024 pm 09:21 PM

How to cancel the automatic jump to Edge when opening IE in Win10_Solution to the automatic jump of IE browser page

How to solve the problem that IE shortcut cannot be deleted How to solve the problem that IE shortcut cannot be deleted Jan 29, 2024 pm 04:48 PM

How to solve the problem that IE shortcut cannot be deleted

See all articles