jquery .css('text-decoration') doesn't work from parents
I have to get needed css property of element (properties may be inherited from it's parent)
Standart jquery .css() can do it.
So i have such an HTML:
&开发者_运维问答lt;div id="container"> some text<br>
<span id="some">Our element</span>
<br> some text
</div>
<div id="result">
</div>
css:
#some {
font-weight:bold;
}
#container {
text-decoration: underline;
color: rgb(0,255,0);
font-size: 32px;
}
and jQuery code:
$(function() {
var decor = $("#some").css('text-decoration');
var weight = $("#some").css('font-weight');
var color = $("#some").css('color');
var size = $("#some").css('font-size');
var result = "<br><b>our object's own property:</b>"
result += "<br>font-weight:" + weight + "<br>";
result += "<br><b>inherited properties:</b><br>";
result += "color: " + color + "<br>font-size: " + size + "<br>text-decoration: " + decor;
$("#result").html(result);
});
All properties are displayed but text-decoration - not. But why? http://jsfiddle.net/aQYs2/
text-decoration is defined with Inherited:no inside the css-specification, but the other properties you use inside your example are defined with Inherited:yes
See: http://www.w3.org/TR/CSS2/text.html#propdef-text-decoration
So everything works really fine :)
精彩评论