Change a text color on click
Moderator: General Moderators
-
fastfingertips
- Forum Contributor
- Posts: 242
- Joined: Sun Dec 28, 2003 1:40 am
- Contact:
Change a text color on click
I would like that if i'm clicking on a button to change the color of a text, how can i do that?
-
jollyjumper
- Forum Contributor
- Posts: 107
- Joined: Sat Jan 25, 2003 11:03 am
Hi FastFingertips,
try this:
Greetz Jolly.
try this:
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';">Greetz Jolly.
Code: Select all
<div style="color:#000000" onclick="this.style.color='#ff0000'>Click to change</div>