Home > Web Front-end > HTML Tutorial > How to press Enter to jump to the next line after typing a line in an HTML form_html/css_WEB-ITnose

How to press Enter to jump to the next line after typing a line in an HTML form_html/css_WEB-ITnose

WBOY
Release: 2016-06-24 12:15:59
Original
3206 people have browsed it

The method I found on the Internet is
This way It does work in IE, but it doesn't work in Google or Firefox. After entering a line, click Enter and submit it directly. How to do it? grateful!


Reply to the discussion (solution)

You should write JS separately

How to do it specifically

onkeydown event and obj.focus( );

Personal test results

onkeydown="if(event.keyCode==13){event.keyCode=9; alert(event.keyCode);}"

IE outputs 9
Firefox outputs 13, no change at all. .

What’s the principle. . Awaiting consultation. . I checked a lot of information and still can't figure it out.

As for how to implement your question:
As mentioned above, the onkeydown event and obj.focus();

1. Judge the enter key in the onkeydown event of the form Shield the onsubmit event,
2. In the onkeydown of the input element, the cursor points to the next input element (because it is similar to event.keyCode=9, the method of using code to implement tab operation... You have also seen that the compatibility is not strong . . )

Use a function

function x() {
var e = arguments[0] || window.event;
if(e.keyCode==13 )e.keyCode=9;
}

Then write the html like this




< input type="text" onkeypress="return handleEnter(this, event)">





document.getElementById("inputId").onkeydown = function(e) {
var e = e || window.e
if(event. keyCode==13)event.keyCode=9 "
}

source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template