Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Updating class styles for IE

Status
Not open for further replies.

toolkit

Programmer
Aug 5, 2001
771
GB
Hi there,

I have a page, where I wish to dynamically change the background color of a specific class of <td> elements. In Netscape's Javascript, I think I can use the classes object to achieve this, but is there anything similar for IE? An example of what I would like to do:

Code:
function setColor() {
    if( targetClass != null ) {
        classes[ targetClass ].backgroundColor = &quot;#FFFFFF&quot;;
    }
}

Thanks for any advice, Neil :)
 
I figured out a DOM-based solution:

Code:
var rows = document.getElementsByTagName( 'tr' );

for( var row = 0; row < rows.length; row++ ) {
    if( rows[ row ].className == targetClass ) {
        rows[ row ].style.backgroundColor = &quot;#FFFFFF&quot;;
    }
}

Cheers, Neil
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top