- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我需要利用这个 DOM 事件。 IE 有 onpropertychange,它也可以做我需要它做的事情。然而,Webkit 似乎不支持这个事件。有没有我可以使用的替代方案?
最佳答案
虽然 Chrome 不发送 DOMAttrModified
事件,自 2011 年以来支持更轻量级的突变观察者,这些也适用于属性更改。
以下是文档正文的示例:
var element = document.body, bubbles = false;
var observer = new WebKitMutationObserver(function (mutations) {
mutations.forEach(attrModified);
});
observer.observe(element, { attributes: true, subtree: bubbles });
function attrModified(mutation) {
var name = mutation.attributeName,
newValue = mutation.target.getAttribute(name),
oldValue = mutation.oldValue;
console.log(name, newValue, oldValue);
}
console.log
声明将打印:
<body color="black">
<script type="text/html">
document.body.setAttribute("color", "red");
</script>
</body>
> color red black
关于dom - 是否有可以在 webkit 中使用的 DOMAttrModified 的替代方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1882224/
我试图在脚本修改 input 元素(文本字段)时触发事件处理程序。在 Internet Explorer 上,我可以使用 onpropertychange 事件,但是在 Firefox 和其他浏览器上
以下是代码 (Jsfiddle demo): Click me! var a = document.body.children[0] a.onclick = function() { alert
我需要检测一些类更改,我将其用于此 DOMAttrModified,但出了点问题,什么? var first_img = $('body').find('li:first').find('img');
应该会触发一些东西,不是吗?我在 IE8 中不受支持,在 Fx 3.6.10 中没有任何反应 // modified from http://pragmatec.blogspot.com/20
我需要利用这个 DOM 事件。 IE 有 onpropertychange,它也可以做我需要它做的事情。然而,Webkit 似乎不支持这个事件。有没有我可以使用的替代方案? 最佳答案 虽然 Chrom
我曾致力于将脚本注入(inject)第三方移动网站。我正在使用 Firefox 的用户代理切换器插件来检查桌面环境中移动网站的元素。 在 Firefox 中,我使用特定 DOM 元素的属性更改中断来测
这个问题已经有答案了: 已关闭12 年前。 Possible Duplicate: is there an alternative to DOMAttrModified that will work
我正在开发一个应用程序,我使用了一个属性,其中 textarea 中的一个小变化应该提醒用户,我尝试了 onChange 事件,但它没有服务器目的,我发现 onPropertyChange 似乎只在
我是一名优秀的程序员,十分优秀!