When there is no border, why IE returns medium while FF returns 0px on the following query ?
.css("border-left-width")
I checked this in FF 3.6.3 and IE 6/7.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Using
css()to read stylesheet-applied styles does different things on different browsers.On IE, it reads values from the IE-specific
currentStyleobject, which is the only way to access this information.currentStylegives you what CSS calls the ‘specified style’, that is to say just what you wrote in the stylesheet. If you haven’t overridden it, the initial value ofborder-widthis ‘medium’ so that’s directly what you get.On other browsers,
css()uses the standard DOM Level 2 CSS methodgetComputedStyle(). Unlike IE’scurrentStyle, this returns the ‘computed style’, which is different from the specified style in that relative units like ‘medium’ are resolved to actual lengths.Here ‘medium’ would normally resolve to a length of about
3px, but you presumably haven’t actually turned the border on for that element, so it defaults toborder-style: none. That makes theborder-widthresolve to zero.Usually the ‘specified style’ and the ‘computed style’ are close enough to each other that you can get away with treating them in the same way, and that’s what jQuery’s
css()method is relying on. But in reality they aren’t quite the same.