#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2002
    Posts
    6
    Rep Power
    0

    how can i change attribute of all css classes?


    say i have a bunch of divs of a particular class. i want to click a button and change an attribute of that class for all the div instances. how could i do that with javascript?

    .myCoolDiv{
    background-color:red;
    }
    .
    .
    .
    <div class="myCoolDiv">blah</div>
    <div class="myCoolDiv">more blah</div>
    < button to change all "myCoolDiv" backgrounds to "blue">
  2. #2
  3. Contributing User
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Apr 2000
    Posts
    1,058
    Rep Power
    22
    www.alistapart.com/index.html has a feature on their page where you can alter the display font with a button click. Check out their code for ideas.


    wdn2k
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2002
    Posts
    6
    Rep Power
    0
    they grab all the tags using getElementByTag and just switch out the style sheets. not quite what i was looking for, but might work
  6. #4
  7. No Profile Picture
    Senior Citizen
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jan 2001
    Location
    leftcoast
    Posts
    2,019
    Rep Power
    16

IMN logo majestic logo threadwatch logo seochat tools logo