[Turn] jsp page press the Enter key trigger event

Reproduced: https://blog.csdn.net/ludongshun2016/article/details/59536779 .


The first:

< Script type = "text / the JavaScript" > 
    function keyOnClick (E) {
     var theEvent = the window.event || E;
     var code = theEvent.keyCode || theEvent.which;
     IF (code == 13 is ) {   // Enter bond is key 13 is 
        Search ();   // call to the search event 
    } 
} 
</ Script > 

< body onKeyDown = "keyOnClick (event);" > 
</ body >

 

 

The second:

<a href="javascript:void(0)" id="searchBtn" onclick="search()">搜索</a>

<input id="searchKeyword" type="text" value="" size="30"
onkeydown="javascript:if(event.keyCode==13) search();"
placeholder="请输入模糊关键字" name="keyword"> 
或:
<input id="searchKeyword" type="text" value="" size="30"
onkeydown= "JavaScript:. IF (== 13 is event.keyCode) document.getElementById ( 'searchBtn') the Click ();" 
placeholder = "Please enter the fuzzy key" name = "keyword" >

 



转载: https://blog.csdn.net/ludongshun2016/article/details/59536779
 

Guess you like

Origin www.cnblogs.com/day1day1up/p/11118831.html