<html> javascript
<head> html
<title>爲數據框添加響應回車事件</title> java
<javascript type="text/javascript"> spa
function searchtest(){ htm
var keywords = document.getElementById('keywords').value; 事件
alert('執行搜索,關鍵字爲:'+keywords); ip
//doSomething get
} input
//相應回車事件 it
function testEnter(){
if(event.keyCode==13) {
searchtest();
return false;
}
}
</javascript>
</head>
<body>
請輸入: <input type="text" id="keywords" onkeypress="testEnter()"/>
<input type="button" name="seachclick" value="搜索" onclick="searchtest()"/>
</body>
</html>