【发布时间】:2015-07-08 20:38:28
【问题描述】:
我正在尝试获取 HTML 元素中样式属性的字符串值。我面临的问题是,如果样式属性的值无效,则结果中会省略该属性。
例子:
<article id="Contact" style="margin: 10px; padding: 10px; color:{Color};">
</article>
var contact = document.getElementById("Contact");
var style = contact.getAttribute("style");
console.log(style); //Prints "margin: 10px; padding: 10px;"
我希望它打印 "margin: 10px; padding: 10px; color:{Color};"
https://jsfiddle.net/wybdL7xk/2/
我是否可以在 Internet Explorer 中获得全部价值?
*Chrome 的工作原理如下所示
【问题讨论】:
-
你用的是什么浏览器?它适用于 Chrome 43。
-
Internet Explorer 11
-
这看起来是特定于浏览器实现的。
-
我明白了.. 谢谢。根据具体情况,这可能是一个好功能或一个坏功能。如果有人想出解决方法,即使似乎无能为力,请发布。
标签: javascript html css typescript