Arcader Posted June 6, 2007 Share Posted June 6, 2007 Hey i've been trying to change the background color of a <td> with javascript, but no success.<script type="text/javascript>document.getElementById('bg').bgcolor='green'</script><table><td id="bg"></td></table>Is there anything I did wrounge with the code? Link to comment Share on other sites More sharing options...
justsomeguy Posted June 6, 2007 Share Posted June 6, 2007 Use the style property instead to change it using CSS properties instead of the HTML attributes.document.getElementById('bg').style.backgroundColor='green'In Javascript, the hyphenated CSS properties like background-color are non-hyphenated and camelcased, like backgroundColor. Also try changing the color name "green" to the hex code, either #00FF00 or #0000FF, I can never remember if that's RGB or RBG. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.