setting text colour using obj.style.color

Discussion in 'JavaScript' started by mitchw, Aug 7, 2009.

  1. #1
    hi all

    i wrote some javascript a while ago which i thought worked to change the colour of some text when it was clicked on. apparently it only works properly in IE and not firefox (not tested in other browsers yet). here is the code

    
    function colourChange(id){
    	if (document.getElementById){
    		obj = document.getElementById(id);
    		if (!obj.style.color | obj.style.color == "#666"){
    			obj.style.color = "#DAA12F";
    		} else {
    			obj.style.color = "#666";
    		}
    	}
    }
    
    Code (markup):
    id is always a list item with a unique id.

    does anyone know why this works correctly in IE but not in FF?
    any help would be greatly appreciated.
     
    mitchw, Aug 7, 2009 IP