日期:2014-05-16  浏览次数:20412 次

JS响应搜索框回车键

<input type="text"

????????? id="research"

????????? value="合肥"

????????? onkeydown="ajaxResearchNode()">

?

在JS中

function ajaxResearchNode(){}

?

?参考博客:

http://blog.sina.com.cn/s/blog_6f1f9ead0100wg4q.html

html:?

?
???????? <input type="text" name="keyword" id="keyword"? onkeydown="entersearch()"/>
???????? <input type="button" onclick="search()"/>
注意:不要用form

js:
function search(){
?? ??? ?$keyword = $("#keyword").val();
?? ??? ?window.location.href = "/list-0-0-0-0-"+$keyword+"-0-0-1.html";
?? ?}
?? ?function entersearch(){
?? ??? ? //alert(dd);
?? ??? ?var event = window.event || arguments.callee.caller.arguments[0];
?? ??? ?if (event.keyCode == 13)
?? ???? {
?? ??? ??? ?search();
?? ???? }
?? ?}