Hello guys, in this my article which is my first here, I will be using JavaScript to change the colour of an element using DOM MANIPULATION.
DOM manipulation is simply document object model manipulation, it has to do with changing styles, texts, contents on a page using JavaScript.
Changing HTML Style
To change the style of an HTML element, use this syntax:
document.getElementById(id).style.property = new style
- Example
<html>
<body>
<p id="p2">Hello World!</p>
<script>
document.getElementById("p2").style.color = "blue";
</script>
</body>
</html>
Happy coding!
Top comments (0)