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();  
           }  
    }  
    
  • 相关阅读:
    项目选题报告答辩总结
    项目UML设计(团队)
    项目选题报告答辩总结
    第七次作业
    结对第二次
    第四次作业
    alpha冲刺4
    alpha冲刺3
    alpha冲刺2
    alpha冲刺1
  • 原文地址:https://www.cnblogs.com/ZhaoxiCheung/p/6914477.html
Copyright © 2011-2022 走看看