jquery监听div、input、textarea内容变化
<p><strong>第一种:change事件</strong></p><p>change事件在元素的值发生变化时触发,适用于input、textarea、select</p>
<pre>
$("#demo").bind("change", function(){
alert('a');
});</pre>
<p><strong>第一种:DOMNodeInserted事件</strong>(插入事件)、<strong>DOMNodeInserted事件</strong>(移除事件)</p>
<pre>
DOMNodeInserted事件只有在插入节点时有效,相反DOMNodeRemoved事件,只有在移除节点时有效。
$('#demo').bind('DOMNodeInserted', function() {
alert('a')
})
$('#demo').bind('DOMNodeRemoved', function() {
alert('b')
})</pre>
<p>textarea监听内容变化</p>
<pre>
$('#sendtxt').bind('input propertychange','textarea',function(){
//#sendtxt为textarea的id
var curLength=$(this).val();
if(curLength == '') $('.foot_add').show(); else $('.foot_add').hide();
});</pre>
<p> </p>
页:
[1]