Change element background with CSS style - Javascript CSS Style Property

Javascript examples for CSS Style Property:background

Description

Change element background with CSS style

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <script type="text/javascript">
function changeTrStyle()/*from w  w w.j  a  v a2  s  . c om*/
{
document.getElementById("trId").style.background = "red";
}

      </script> 
   </head> 
   <body> 
      <table> 
         <tbody>
            <tr id="trId"> 
               <td> 
                  <input type="text" onfocus="changeTrStyle()"> 
               </td> 
            </tr> 
         </tbody>
      </table>  
   </body>
</html>

Related Tutorials