<html>
<head></head>
<title></title>
<body>
<p id="para1">Hello John</p>
<p id="para2">Hello Steward</p>
<script>
//document.getElementById('').style.property = "new style";
//Applying one css property
document.getElementById('para1').style.color = "red";
//setAttribute adds new attributes
//Applying multiple css property
document.getElementById('para2').setAttribute("style","color:blue; text-align:center;");
</script>
</body>
</html>
Output:
Hello John
Hello Steward
No comments:
Post a Comment