Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Apr 2005
    Thanked 0 Times in 0 Posts

    changing style to multiple targets (class, id ??)


    I've been trying to find the answer, but none of them seems to fit my needs, so I'm asking for help now

    Here's the thing...

    I've got a huge table, dinamicaly created by php, but I can still put any tag (class, id, whatever) on those cells (about 2.000 cells). Imagine I want to change the font-color of all the cells with some tag (example: all the cells with "class=mouse" yould now have blue font)

    Is there a away to do it without using "for" to visit every cells on the table?

    I've been able to do something like that with this:
    function test()
    	if (!document.styleSheets) return;
    	var theRules = new Array();
    	if (document.styleSheets[0].cssRules)
    		theRules = document.styleSheets[0].cssRules
    	else if (document.styleSheets[0].rules)
    		theRules = document.styleSheets[0].rules
    	else return;
    	theRules[3].style.font = 'blue';  //Edited to reflect the example, no sure if it works
    But that requiered of having that class defined on the css style sheet... but I have a dinamic table, so I can't have that...

    Is there a way to change that utilizing tags like class or id?
    Thanks for the help


  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Thanked 256 Times in 252 Posts
    If I understood you correctly, just specify this rule in your CSS and all cells of the table with id tbl will have your desired color without specifying class for each cell.

    #tbl td {
    <table id="tbl">

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins


    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts