zoukankan      html  css  js  c++  java
  • input内容改变触发事件,兼容IE

    <html>
    
    <head>
    <script type="text/javascript">
    window.onload = function(){
        myFunction = function(){
            console.log("1");
        }
    
    }
     
    </script>
    </head>
    
    <body>
    
    Enter your name: <input type="text" id="fname" oninput="myFunction()" onpropertychange="myFunction()">
    
    </body>
    </html>




    <html>
    
    <head>
    <script type="text/javascript">
    window.onload = function(){
        myFunction = function(){
            console.log("1");
        }
        var oTest = document.getElementById('fname');
        if(oTest.attachEvent){
                oTest.attachEvent('onpropertychange',function(){    
                   console.log("1");        
            });
        }
        else{
            oTest.addEventListener('input',function(){
                console.log("1");  
            }
                );
        }
    
    }
     
    </script>
    </head>
    
    <body>
    
    Enter your name: <input type="text" id="fname">
    
    </body>
    </html>
    
    
    
     

    <html>

    <head>
    <script type="text/javascript">
    window.onload = function(){
        myFunction = function(){
            console.log("1");
        }

    }
     
    </script>
    </head>

    <body>

    Enter your name: <input type="text" id="fname" oninput="myFunction()" onpropertychange="myFunction()">

    </body>
    </html>

  • 相关阅读:
    lambda函数用法
    Appium基础篇-元素定位
    python生成测试报告
    jmeter 设置中文
    jmeter bin下常用目录
    高效求幂运算
    欧几里德算法(求最大公因数)
    二分查找
    最大子序列和问题
    秋游小记
  • 原文地址:https://www.cnblogs.com/liucanhao/p/5983319.html
Copyright © 2011-2022 走看看