<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>131</title>
<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.0.js"></script>
<head>
</head>
<body>
<form>
<input type="text" id="txtName"/>
<input type="reset" id="submit" style="display: none;"/>
</form>
<script language="JavaScript">
$(document).ready(function () {
$("#txtName").keydown(function (e) {
var e = event ||window.event;
if (e.keyCode == 13) {
$("#submit").click()
}
});
});
</script>
</body>
</html>
<html>
<head>
<meta charset="UTF-8">
<title>131</title>
<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.0.js"></script>
<head>
</head>
<body>
<form>
<input type="text" id="txtName"/>
<input type="reset" id="submit" style="display: none;"/>
</form>
<script language="JavaScript">
$(document).ready(function () {
$("#txtName").keydown(function (e) {
var e = event ||window.event;
if (e.keyCode == 13) {
$("#submit").click()
}
});
});
</script>
</body>
</html>
本文介绍了一种使用jQuery简化网页表单输入处理的方法。通过监听文本框输入元素的键盘事件,实现当用户按下Enter键时触发表单提交功能。这种方法提高了用户体验,使表单交互更加流畅。
121

被折叠的 条评论
为什么被折叠?



