getElementId change color of text

Hi site point people,

I have been playing with javascript and I have one issue I can’t workout. below in my code on a click the td will change
its background image and text color. The issue I have I can’t get the color to work but the image is find. Any help would be
great thanks

         <a href="javascript:cont(specialId)" class="position-one"><span>water</span></a>

function cont(specialId){
document.getElementById(specialId).style.backgroundImage = "url(select-buttons/selected.png)";
document.getElementById(specialId).style.color = "orange";

A few points:

<a [COLOR=#ff0000]href="javascript:cont(specialId)" [/COLOR]class="position-one"><span>water</span></a

is bad. href is meant to be used to navigate to another page, not run javascript.

A better way is

<a href="" onclick="cont('specialId'); return false;" class="position-one"><span>water</span></a>
  1. where have you defined specialId in javascript:cont(specialId)?

You can do it this way:

<a href="#" id="specialId" class="position-one"><span>water</span></a>

var spcID = document.getElementById('specialId');
	spcID.onclick = function(e) {
		e.preventDefault(); = "url(select-buttons/selected.png)"; = "orange";

thanks I have made the changes I have the special id in the the td it is dynamically written by the php.

<td id=“specialId”> // sorry left that bit out

ok :), then you would also need to wrap the argument in your call to cont in quotes.

thanks for your help