Home >Web Front-end >JS Tutorial >Enter directly to achieve the effect of clicking a button and trigger the click event_javascript skills

Enter directly to achieve the effect of clicking a button and trigger the click event_javascript skills

WBOY
WBOYOriginal
2016-05-16 16:57:481680browse
Copy code The code is as follows:

//Enter to trigger a click event of a button
< ;input name="" type="text" class="input_search fl" id="searchkey" onkeydown="globelQuery(event);"/>
Search


http://img.blog.csdn.net/20140227095828937?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvYmFpY3Az/font/5a6L5L 2T /fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast
Copy code The code is as follows:

//Search enter to achieve click effect//Compatible with IE Firefox and Google
function globelQuery(e) {
if (!e)
e = window.event;
if ((e.keyCode || e.which) == 13) {
$("#globelSearch").click();
}
}
Statement:
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