Website Scripts And Cloud Tutorials

How to change font Family | color using javascript

Byadmin

Oct 1, 2013 ,

Last updated on February 14th, 2022 at 01:27 pm

Click to rate this tutorial!
[Total: 2 Average: 5]

Change font Family, Style, Size, color using Javascript

DOM is always useful for a web developer to dynamically change content inside a webpage. Here is a simple script that provide real time change of font size along with font family, size, style and color

<html>
<head>
<script>
function displayResult()
{
document.getElementById("p1").style.fontFamily="Helvetica";
document.getElementById("p1").style.fontStyle="oblique";
document.getElementById("p1").style.fontSize="xx-large";
document.getElementById("p1").style.color="Red";
}
</script>
</head>
<body>
 
<p id="p1">This text is going to change soon :-)</p>
<br>
 
<button type="button" onclick="displayResult()">Change Font Style, Familym Color and Size</button>
 
</body>
</html>
Click to rate this tutorial!
[Total: 2 Average: 5]
One thought on “How to change font Family | color using javascript”

Leave a Reply

Your email address will not be published.