如何找到哪些JavaScript正在更改元素的风格? [英] How do I find which JavaScript is changing an element's style?
本文介绍了如何找到哪些JavaScript正在更改元素的风格?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
解决方案
如果你是确定它是内置的样式
而不是样式表规则的结果,您可以使用非标准的Mozilla watch()方法:
document.body.style.watch('color',function(name,v0,v1){
alert(name +':'+ v0 +' - >'+ v1);
});
document.body.style.color ='red';
您可以在观察者中放入调试器;
功能,并在Firebug中查找调用堆栈,以查看更改被触发的位置。
I have an element that's getting styles applied via JavaScript. I'm not sure exactly where; is there a way to check Firebug to show where the "element.style" is actually coming from?
解决方案
If you're sure it's being set on the inline style
and not as a consequence of a stylesheet rule, you can detect changes using the non-standard Mozilla watch() method:
document.body.style.watch('color', function(name, v0, v1) {
alert(name+': '+v0+'->'+v1);
});
document.body.style.color= 'red';
You can put debugger;
in the watcher function and look up the call stack in Firebug to see where the change was triggered.
这篇关于如何找到哪些JavaScript正在更改元素的风格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文