Change Font Size and Color of text using Java Script

-- Leave a Comment
Change the font size and color of the text using java script We use onmouseover in this example code. You can use onClick and onmouseout too.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<html>
<head>
 <title>Display a table</title>
</head>
<body>
 <p id="Hello" onmouseover="change(this)">Hello How are you doing</p>
 <script>
 function change(obj){
  obj.style.margin = "90px";
  obj.style.fontSize = obj.style.fontSize == "200%" ? "300%" : "200%";
  obj.style.color= obj.style.color=="green" ? "red" : "green"; 
 }
 </script>
</body>
</html>


Hello This is Sagar Devkota. Studying Bachelor of Software Engineering at Pokhara University, NCIT. Open Source Enthusiastic.

0 comments:

Post a Comment