I am new to webdesign, and have a question. As I understand it, you can code styles via CSS, or in JS (on the HTML side). In the end, the DOM is the repository of all of these "actions".
Now, if I have an HTML document with associated styles in a CSS, can I override the CSS through JS (written over in the HTML side) by directly changing the DOM?
Update:
@treddie You have to make sure that any JavaScript that references elements in the DOM is processed after those DOM elements have been parsed into memory. For that reason, we often advise people to place their element just before the closing body tag (). – Scott Marcus
Sounds like what I was trying to do, and I tried putting the following Javascript at the bottom of the HTML body and nothing happened.
<script>
x1t=x1r.toString(); /* x1r was calculated earlier in this script */
var Product_Linky = document.getElementById("Product_Link_Container");
Product_Linky.style.left=x1t;
</script>
</body>
But I'm not surprised...I am totally new to HTML, CSS, JS.
This question already has an answer here:
Changing element style attribute dynamically using JavaScript 10 answers
Sorry...It's hard to find the existing questions when you do not know what words were used so that you can search for the correct phrases. But thanks for the 3 upvotes! (I always do Abs(votes)).