JavaScript HTML DOM changing CSS #Part 9
In this article we are lean to how we change HTML CSS using getElementByID.
HTML DOM allows JavaScript to change the style of HTML elements.
Syntax
document.getElementById(id).style.property = 'new style';
HTML and JavaScript Code
<p id="p1">My name is Bharatsinh and this is my blog. My blog name is codepocket.tk. In this blog you will get information about programming Languages, HTML, CSS, Javascript, Bootstrap Internet, websites, apps, softwares, tech tricks and tips, and other useful information.</p>
<button onclick="myfun()">click Me</button>
<script>
function myfun()
{
document.getElementById('p1'). style.fontFamily='cursive';
}
</script>
Try it Yourself...
what you think about this article ??