View Full Version : change the background color of the td onclick
developerhusain
05-27-2013, 10:48 AM
Hi guys
I want to change the background colour of the td and also the colour of the link when you click on it.Cna you please help me out
Developer husain
jscheuer1
05-27-2013, 01:36 PM
The simplest way is:
<td onclick="this.style.backgroundColor = 'red';">Whatever</td>
You can do a link the same way, but a link will usually take you away from a page. So you can use css style instead:
<style type="text/css">
a:link {background-color: blue;}
a:active {background-color: red;}
a:visited {background-color: red;}
</style>
Often when someone asks this question they want all tds in the table except the one clicked to be one background color and the clicked one to change to another background color. Is that what you want?
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.