Hi I am inserting text in html page using javascript..But the font-color of this text is black by default. How to change the color of this text?? I am using createTextNode() and appendChild() functions to insert the text but not able to change the color using style.color property. How to accomplish this? Please help.. Thanks a lot...
Hi, You can check this Code: <button onclick="myFunction()">Try it</button> <script> function myFunction() { var h = document.createElement("H1"); h.style.color="red"; var t = document.createTextNode("Hello World"); h.appendChild(t); document.body.appendChild(h); } </script> Thanks