【发布时间】:2010-12-21 12:17:42
【问题描述】:
我正在努力做到这一点,当用户在文本框中并按下回车键时,它与单击链接相同,在这种情况下,它应该将他们带到另一个页面。这就是我所拥有的,但它不起作用。
代码
//jQuery
$(document).ready(function() {
//if focus is in the input box drivingSchoolInput
$("#drivingSchoolInput").live("click", function() {
//if enter key is pressed
if(e.keyCode == 13) {
//click the button and go to next page
$("#button1").click();
}
});
});
标记
<form>
<div class="formDiv">
<label for="City">Search by Driving School</label>
<span class="inputBox"><input type="text" name="City" class="input" id="drivingSchoolInput" /></span>
</div>
<h4 class="submitButton"><a href="school.html" id="button1">Submit</a></h4>
</form>
【问题讨论】:
标签: javascript jquery dom javascript-events