zoukankan      html  css  js  c++  java
  • js判断文本框里面输入内用以后是否有回车 (兼容FF和IE)

       <html>  
        <body>  
        <script type="text/javascript">  
        function noNumbers(e)  
        {  
        var keynum;  
         
          
        if(window.event) // IE  
            {  
            keynum = e.keyCode;
                  
            }  
        else if(e.which) // Netscape/Firefox/Opera  
            {  
            keynum = e.which;  
            }  
         if(keynum==13)
         {
            
            alert(document.getElementById("keyWord").value);
            return false;
         }
        }  
        </script>  
          
        <form>  
        Type some text (numbers not allowed):  
        <input id="keyWord" name="keyWord" type="text" onkeydown="return noNumbers(event)" />  
        </form>  
          
        </html> 

     以下方法是其他版本 大家可以试下

    <script type="text/javascript">
        document.onkeydown = function(e){
            if(!e) e = window.event;//火狐中是 window.event
            if((e.keyCode || e.which) == 13){
                document.getElementByIdx_x_x("auto").click();
            }
        }

    </script>
     

  • 相关阅读:
    移动web开发之flex布局(弹性布局)
    移动web开发之流式布局
    移动端基础
    3D变形(CSS3) transform
    动画(CSS3) animation
    2D变形(CSS3) transform
    过渡(CSS3)
    CSS精灵技术(sprite)
    字体图标
    伸缩布局(CSS3)
  • 原文地址:https://www.cnblogs.com/kaixinmenghuan/p/2061452.html
Copyright © 2011-2022 走看看