Last updated on January 10th, 2023 at 02:03 pm

The font color, family and size of the text the id named p1 will be changed when user click the button. DOM(Document Object Model) 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

function displayResult()
<p id="p1">This text is going to change soon :-)</p>
<button type="button" onclick="displayResult()">Change Font Style, Family Color and Size</button>

We are using document.getElementById(“p1”).style to make these changes. I have created a function with all the details as shown above.


One thought on “How to change font Family color using javascript”

Leave a Reply

Your email address will not be published. Required fields are marked *