`

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();
        }
    }
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics