IE 中 HTML pseudo element 的 style 取得(论坛回复摘要)
2013-03-20 23:24
302 查看
问题
HTML 文件
在 IE 中,如何取得 "<div
class="m">" 的 pseudo element ":before" 的 content 值?
答复
In IE8, it is a mission impossible. 在 IE8, 这大概是不可能的。因为,content 是用来定义 pseudo elements (比如,:before, :after).
currentStyle, 是一般 DOM element 的属性,不能用于pseudo elements。
首先,你就无法得到 pseudo elements (比如说用 getElementById)
到了 IE9,微软也引入支持getComputedStyle(element, pseudo). 才有可能。
连接
原贴:http://bbs.csdn.net/topics/390396139
HTML 文件
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>new document</title> <style type="text/css"> .m:before { content: "asdf"; } .m { color: #ff0000; } </style> </head> <body> <div class="m">777</div> <script type="text/javascript"> alert(document.querySelectorAll(".m")[0].currentStyle.content); </script> </body> </html>
在 IE 中,如何取得 "<div
class="m">" 的 pseudo element ":before" 的 content 值?
答复
In IE8, it is a mission impossible. 在 IE8, 这大概是不可能的。因为,content 是用来定义 pseudo elements (比如,:before, :after).
currentStyle, 是一般 DOM element 的属性,不能用于pseudo elements。
首先,你就无法得到 pseudo elements (比如说用 getElementById)
到了 IE9,微软也引入支持getComputedStyle(element, pseudo). 才有可能。
连接
原贴:http://bbs.csdn.net/topics/390396139
相关文章推荐
- HTML 多个下拉框联动 JS 示例代码(论坛回复摘要)
- JavaScript 的一道有趣考题 (论坛回复摘要)
- Java 多线程测试示例代码 (论坛回复摘要)
- document.getElementById("id").innerHTML=""与document.getElementById("id").style.display="none"
- IE 8 HTML Parsing Error: Unable to modify the parent container element before the child element is closed (KB927917)
- JavaScript 中 Construct 步骤 (论坛回复摘要)
- IE Devtoolbar的Element Source功能(获取js生成HTML源码)
- MathML 及数学公式的编辑器 MathJax (论坛回复摘要)
- IE 8 HTML Parsing Error:Unable to modify the parent container element before the child element is cl
- HTML中element.style取值问题
- IE 8 HTML Parsing Error: Unable to modify the parent container element before the child element is closed (KB927917)
- JavaScript 如何导入最少执行的 log 打印函数(论坛回复摘要)
- 【报错】IE 8 HTML Parsing Error:Unable to modify the parent container element before the child element is closed
- html页面中显示审查元素时Element.style
- IE 8 HTML Parsing Error:Unable to modify the parent container element before the child element is cl
- IE8"HTML Parsing Error:Unable to modify the parent container element before the child element is closed"错误
- IE中实现HTMLElement
- Java 如何提取 XML 文件的文本内容(论坛回复摘要)
- javascript HTMLElement IE隐藏了这个属性
- IE 8 HTML Parsing Error: Unable to modify the parent container element before the child element is c