zoukankan      html  css  js  c++  java
  • JavaScript搜索框响应事件

    HTML页面,注意:不要使用form标签

    <input type = "text" name="keyword" id="keyword"  onkeydown="entersearch()"/>  
    <input type = "text" name="keyword" id="keyword"  onkeydown="entersearch1(event)"/>  
    <input type = "button" onclick="search()"/>  
    
    1<input type = "text" name="keyword" id="keyword"  onkeydown="entersearch()"/>
    2<input type = "text" name="keyword" id="keyword"  onkeydown="entersearch1(event)"/>
    3<input type = "button" onclick="search()"/>
    

    Javascript实现方法

    // onclick事件  
    function search(){  
        var $keyword = $("#keyword").val();  
        window.location.href = "/list-0-0-0-0-"+$keyword+"-0-0-1.html";  
    }  
      
    // 按Enter键,执行事件  
    function entersearch(){  
        var event = window.event || arguments.callee.caller.arguments[0];  
        if (event.keyCode == 13)  
           {  
              search();  
           }  
    }  
      
    // 按Enter键,执行事件  
    function entersearch1(event){  
        if (event.keyCode == 13)  
           {  
              search();  
           }  
    }  
    
  • 相关阅读:
    C语言I博客作业06
    C语言I博客作业05
    C语言I博客作业04
    C语言I博客作业03
    C语言I博客作业02
    第一次作业
    C语言I博客作业09
    C语言I博客作业08
    C语言I博客作业07
    C语言I博客作业06
  • 原文地址:https://www.cnblogs.com/ZhaoxiCheung/p/6914477.html
Copyright © 2011-2022 走看看