zoukankan      html  css  js  c++  java
  • 关于回车直接执行事件的方法

    1.form表单实现

    <html>
    <form name="f1" method="post" action="login.asp">
    用户名:<input type="text" name="fuser"><br>
    密 码:<input type="password" name="fpwd"><br>
    <input type="submit" name="b1" value="提交">
    </html>

    2.jQuery触发事件

    <div>
      <input type="text" id="search" name="search" size="28"/>
      <button id="go">GO</button>
    </div>
    <div id="result" class="result"></div>
    
    <script type="text/javascript">
    $(document).ready(function(){
        var txt = $(":text");
        $(this).keyup(function(e){  	
            if(e.keyCode == 13){
               txt.focus();
            }   
        });
    	
        txt.keyup(function(e){
        if(e.keyCode == 13){
        	$("#go").click();
        }	
        });
    });
    
    $(document).ready(function() { 
        $("#go").bind('click',function(){ 
    	var search = $("#search").val();		
    	var resultmsg = "Your are searching text"+"<b>"+'\"'+search+'\"'+"</b>";	
    	$("#result").html(resultmsg);
    	$("#search").val(""); //clear search text	
        }); 
    });
    </script>


  • 相关阅读:
    C++ std::stack 基本用法
    linux6 安装 ntopng
    linux 6安装 redis2.6
    Linux6搭建Tomcat服务器
    EXSI6.5忘记root密码
    python3笔记--数字
    python3笔记--运算符
    python3基本数据类型
    python3笔记
    centos6.X升级python3.X方法
  • 原文地址:https://www.cnblogs.com/phil_jing/p/15615901.html
Copyright © 2011-2022 走看看