[英]How to get a style attributes from a CSS class if there are more than two CSS classes?
.css .css
.Fchkbox, .Fchkbox-lg {
position: absolute;
display: block;
margin-top: 10px;
}
Here I am getting style attribute value if 如果我在这里获得样式属性值
1>getStyleRuleValue("margin-top",".Fchkbox");
result:-10px;
2>getStyleRuleValue("margin-top", ".Fchkbox-lg");
So here I am not getting the result as 10px....why? 所以在这里我没有得到10px的结果。 How can I resolve this?
我该如何解决?
Regarding the method described in this article : How to get a style attribute from a CSS class by javascript/jQuery? 关于本文中描述的方法: 如何通过javascript / jQuery从CSS类获取样式属性? the code should be tweaked.
该代码应进行调整。 The stylerule is split on a comma into an array of different selectors.
样式规则以逗号分隔为不同选择器的数组。 You should split on comma including whitespace.
您应该对逗号进行分隔,包括空格。
rule.selectorText.split(/,\\s?/)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.