我想让脚本在DIV的内容发生更改时执行,以另一种方式,我想听听特定的节点/子项更改,在这个小提琴中,我在JavaScript中找到了一个名为“ DOMSubtreeModified”的内容,
$("#someDiv").bind("DOMSubtreeModified", function() {
alert("tree changed");
});
DART中有类似的东西吗?
感谢@Gunter Zochbauer,以及您提供的推荐站点,我在DART中找到了有关MountainObserver的内容,下面的代码对我来说很完美:)
main(){
...
Element myDiv = querySelector('#my-element');
var observer = new MutationObserver((mutations, _) {
mutations.forEach((mutation) {
print('number of direct nodes here are: ${myDiv.nodes.length}');;
});
});
observer.observe(myDiv, childList: true);
....
}
在index.html中,我已经:
<div id='my-element'></div>
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句