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


第一种:

<script type="text/JavaScript">
    function keyOnClick(e){
    var theEvent = window.event || e;
    var code = theEvent.keyCode || theEvent.which;
    if (code==13) {  //回车键的键值为13
        search();  //调用搜索事件
    }
}
</script>

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

 

 

第二种:

<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(event.keyCode==13) document.getElementById('searchBtn').click();"
placeholder="请输入模糊关键字" name="keyword">

 



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

相关文章:

  • 2022-12-23
  • 2021-11-27
  • 2021-07-30
  • 2022-12-23
  • 2021-12-16
  • 2021-10-11
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-05
相关资源
相似解决方案