Here's an example block of css:
p {
position: relative;
color: blue;
font-size: 100%;
top: 100px
}
Then if I include a paragraph tag which calls a javascript function upon being clicked:
<p onclick="logStyles(this)">Test</p>
Strangely, only some styles are accessible...
function logStyles(obj) {
console.log(obj.style.color);
console.log(obj.style.position);
console.log(obj.style.fontSize);
};
The element's color value shows up in the console and I am able to change it's value to say "blue" from my javascript. But the second two functions log nothing to the console and those style values are inaccessible.
red page.html:16
page.html:17
page.html:18
Why is this the case? I am running the latest version of Chrome.
The css and javascript files are included through links in the head as so:
<script src="js_methods.js"></script>
<link rel="stylesheet" type="text/css" href="stylesheet.css">