目录

  • 1、在元素上同时绑定 oninput 和onporpertychanger事件
  • 2. 使用原生js添加监听事件
  • 3. 使用jQuery方法绑定事件

1、在元素上同时绑定 oninput 和onporpertychanger事件

<script type="text/JavaScript">
function aa(e){alert("inputting!!");}
</script>
<input type="text" id="a" oninput="aa(event)" onporpertychange="aa(event)" />

2. 使用原生js添加监听事件

<script type="text/javascript">
 $(function(){
if("\v"=="v"){//true为IE浏览器,感兴趣的同学可以去搜下,据说是现有最流行的判断浏览器的方法
document.getElementById("a").attachEvent("onporpertychange",function(e){
console.log("inputting!!");
}
}else{
document.getElementById("a").addEventListener("onporpertychange",function(e){
console.log("inputting!!");
}
}
});
</script>
<input type="text" id="a"/>

3. 使用jQuery方法绑定事件

<script type="text/javascript">
 $(function(){
$("#a").bind('input porpertychange',function(){
console.log("e");
});
});
</script>
<input type="text" id="a"/>
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。