我无法按Enter键来点击搜索按钮....请帮帮我。提前谢谢。
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
........
<script type="text/javascript" src="js/jquery.js"></script>
<script src="../jQueryAssets/jquery-1.8.3.min.js" type="text/javascript"></script><script type="text/javascript">
function get() {
$.post ('data/data.php', { word: form.name.value },
function (output) {
$('#defination') .html(output).show() ;
});
}
</script>
.............
<form name ="form">
<div align="center">
<pre> <input name="name" type="text" autofocus required placeholder="Please enter a Word !" size = "70" maxlength="50" >
</pre>
<p>
<input type="button" onClick="get();" value="Search" size = "30" >
.........
</html>
答案 0 :(得分:2)
您可以使用JQuery提交表单。
$(document).bind("keydown", function(event){
if(event.which=="13")
{
$("#buttonID").click();
}
});
答案 1 :(得分:0)
这也有效:
$(document).bind("keydown", function(event){
if(event.which=="13")
{
$("form").submit();
}
});