我有一个样式为
resize: both
的DIV
,然后我设置了一个MutationObserver
来监听属性变化。mutObs = new MutationObserver(function () {
console.log('Hello');
});
elem = document.getElementById('aDiv');
mutObs.observe(elem, {
attributes: true
});
elem.style.width = '300px'; //this fires the observer callback as expected
我做了一个示例: http://jsfiddle.net/2NQQu/2/
在Chrome浏览器中(我测试的是Chrome 31),当您使用鼠标调整
大小时,回调函数不会被触发。但是在Firefox中,它可以正常工作。
这种行为是有意为之和/或标准吗? 这是一个错误吗?