/ Published in: CSS
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<html> <head> <title>Click the color name to change the text color: </title> <style type="text/css"> .red {color:red} .green {color:green} .blue {color:blue} </style> </head> <body> <center> <h4>Click the color name to change the text color: </h4> <table width="70%" border="1" cellspacing="3" cellpadding="3"> <tr> <td width="25%"><a href="#; return false;" onClick="document.all.one.className='red'" onMouseOver="this.style.background='red';this.style.color='white';" onMouseOut="this.style.background='';this.style.color='';">Red</a> </td> <td rowspan="3"><span id="one">Click the color name to change the text color. This is changing className by javascript.</span> </td> </tr> <tr> <td><a href="#; return false;" onClick="document.all.one.className='green'" onMouseOver="this.style.background='green';this.style.color='white';" onMouseOut="this.style.background='';this.style.color='';">Green</a> </td> </tr> <tr> <td><a href="#; return false;" onClick="document.all.one.className='blue'" onMouseOver="this.style.background='blue';this.style.color='white';" onMouseOut="this.style.background='';this.style.color='';">Blue</a> </td> </tr> </table> <br> </center> </body> </html>