Changing the style of an HTML element, is a variant of changing an HTML attribute,
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript change the font color</h1>
<p id="demo">JavaScript change the style of an HTML element.</p>
<script>
function myFun() {
var x = document.getElementById("demo");
x.style.fontSize = "25px";
x.style.color = "red";
}
</script>
<button type="button" onclick="myFun()">Click Me!</button>
</body>
</html>
Result :
1. Before Click
JavaScript change the font color
JavaScript change the style of an HTML element.
2. After Click
JavaScript change the font color
JavaScript change the style of an HTML element.
0 comments:
Post a Comment
Thanks For Coming The Page.