JS/jQuery 之change、keypress、input和propertychange


$(function(){
/**
* a、当前对象属性改变,并且是由键盘或鼠标事件激发的(脚本触发无效)
* b、当前对象失去焦点(onblur)
*/
$("#change").change(function(){
console.log("change="+$(this).val());
});

/**
* a、keypress/keydown/keyup监听键盘事件,鼠标复制黏贴操作无效
*/
$("#keypress").keypress(function(){
console.log("keypress="+$(this).val());
});

/**
* a、input是标准的浏览器事件,一般应用于input元素,当input的value发生变化就会发生,无论是键盘输入还是鼠标黏贴的改变都能及时监听到变化
* b、propertychange,只要当前对象属性发生改变。
*/

$(".center").delegate(".center_comment" ,"input propertychange " ,function(){
  console.log ($(this).val())
  })

});
</script>
</html>


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM