开发者

calling function based on dom change

开发者 https://www.devze.com 2022-12-08 21:21 出处:网络
I rewrote a bit of my code based on that it\'s not really feasible to check to see if a javascript variable changes. But, how would I do it with a dom element? For instance

I rewrote a bit of my code based on that it's not really feasible to check to see if a javascript variable changes. But, how would I do it with a dom element? For instance

<div id='foo'>123</div>
<scr开发者_如何学编程ipt>
$('#foo').html('456');
// function gets fired since #foo changed.
</script>

I tried

$("#foo").change(function () {
      alert('change!');
    })
    .change();

but no luck.


See:

  • Detect div content changes with jquery
  • Custom events in jQuery open doors to complex behaviors
0

精彩评论

暂无评论...
验证码 换一张
取 消