回车键搜索

  今天写了个 搜索  想来发表发表 

  

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<input type="text" name="keyword" id="keyword" onkeydown="entersearch()"/>
<input type="button" value="搜索" onclick="search()"/>

<script src="jquery.js"></script>
<script>
function search(){
console.log('点击了 1111')
}
function entersearch(){
//alert(dd);
var event = window.event || arguments.callee.caller.arguments[0];
if (event.keyCode == 13)
{
search();
console.log('点击了 2222')
}
}
</script>
</body>
</html>

如有不足,还请大神指点一二

原文地址:https://www.cnblogs.com/BeautifulBoy/p/6721809.html