jquery监听div、input、textarea内容变化

第一种:change事件

change事件在元素的值发生变化时触发,适用于input、textarea、select

$("#demo").bind("change", function(){
    alert('a');
});

第一种:DOMNodeInserted事件(插入事件)、DOMNodeInserted事件(移除事件)

DOMNodeInserted事件只有在插入节点时有效,相反DOMNodeRemoved事件,只有在移除节点时有效。
$('#demo').bind('DOMNodeInserted', function() {
   alert('a') 
})
$('#demo').bind('DOMNodeRemoved', function() {
   alert('b') 
})

textarea监听内容变化

$('#sendtxt').bind('input propertychange','textarea',function(){
  //#sendtxt为textarea的id
var curLength=$(this).val(); if(curLength == '') $('.foot_add').show(); else $('.foot_add').hide(); });

 

posted @ 2019-04-15 16:47  十三月凉  阅读(2407)  评论(0编辑  收藏  举报
/* 看板娘 */