Reputation: 220
I know that the jQuery css()
method works with CSS rules set in a <style>
tag or in the style
attribute of an HTML element, but does it work with an external stylesheet?
For example if I have <p id="test">
in my HTML file and in an external stylesheet this code:
#test {
visibility: hidden;
}
Would $("#test").css("visibility");
return hidden
?
Upvotes: 2
Views: 92
Reputation: 510
Yes, when you use $("#test").css("visibility")
you are getting the value of visibility property.
If you want to set a value you can add the second parameter example:
$("#test").css("visibility","visible"); // setting visible to the visibility property
// then if you test :
if($("#test").css("visibility") === "visible") // will return true;
It's a object that accept key and value.
Upvotes: 1
Reputation: 337627
The css()
method will read all the CSS properties on the specified element, no matter where or how they were set. So short answer, yes.
Upvotes: 5