in the html file i have this code: how i change the color of the td ? HTML Code: <table width=600 id=games> <td id=2_$id style='background-color:' onclick='bet_detils($teamav, $id, $x2);'> <B> <font face=Arial size=1 color=bb2618> <div align=right><a href='javascript: void(0);'>$teamav</a></td> in the java i have this.... function bet_detils(yahs,idz,chose) { var idfinish=chose+'_'+idz; idfinish.style.backgroundcolor=blue; } how i call to the this td from a function
Try this: HTML: <td id='someID'>blah blah blah</td> <a href="javascript:void(0);" onclick="changeColor('someID')">Click to change color</a> JAVASCRIPT: function changeColor(id) { document.getElementById(id).style.backgroundColor = '#000AFF'; } Remember, most CSS attributes are represented as properties in the Style object. For non hyphenated attributes, the property is identical, while for hyphenated attributes, drop the hyphen and capitalize the first letter following it. For instance, to manipulate the "background-color" property of CSS via the DOM, the syntax would look something like: document.getElementById("ID").style.backgroundColor="white"; CSS: background-color Javascript: backgroundColor