<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script type="text/javascript" src="jquery.js"></script>
<script>
$(function(){
$("#t1").keydown(function(){
if (event.keyCode == "13") {//keyCode=13是回车键
alert("文本回车事件")
}
});
$("#s1").keydown(function(){
if (event.keyCode == "13") {//keyCode=13是回车键
alert("下拉框回车事件")
}
});
$("body").keydown(function(){
if (event.keyCode == "13") {//keyCode=13是回车键
alert("body回车事件")
}
});
});
</script>
</head>
<body>
<select id="s1">
<option value="1">第一</option>
<option value="2" selected="selected">第二</option>
<option value="3">第三</option>
</select>
<input type="text" id="t1"/>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script type="text/javascript" src="jquery.js"></script>
<script>
$(function(){
$("#t1").keydown(function(){
if (event.keyCode == "13") {//keyCode=13是回车键
alert("文本回车事件")
}
});
$("#s1").keydown(function(){
if (event.keyCode == "13") {//keyCode=13是回车键
alert("下拉框回车事件")
}
});
$("body").keydown(function(){
if (event.keyCode == "13") {//keyCode=13是回车键
alert("body回车事件")
}
});
});
</script>
</head>
<body>
<select id="s1">
<option value="1">第一</option>
<option value="2" selected="selected">第二</option>
<option value="3">第三</option>
</select>
<input type="text" id="t1"/>
</body>
</html>