Change a text color on click
Posted: Sun Jan 11, 2004 2:15 pm
I would like that if i'm clicking on a button to change the color of a text, how can i do that?
A community of PHP developers offering assistance, advice, discussion, and friendship.
http://forums.devnetwork.net/
Code: Select all
<span id="texttochangecolor" style="color:#000000;">
This is a black text. When you click the button it will turn red.
</span>
<input type="button" value="Change color" onclick="document.getElementById('texttochangecolor').style.color='#FF0000';">Code: Select all
<div style="color:#000000" onclick="this.style.color='#ff0000'>Click to change</div>