Results 1 to 2 of 2

Thread: Pls help with setting style

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2001
    Location
    Three Anchor Bay, Cape Town, South Africa
    Posts
    769

    Pls help with setting style

    Hi,

    I have a few thousand elements to which I have a style class assigned ( customdiv ). I would like to change a style property ( fontsize ) of all of these elements at once using scripting. I know I can use a java loop, but this will be really slow. I know that I could also change the className attribute of each element, but 1) this comes back to the slow loop issue, and 2) I would need a million classes for each combination of values.

    So what I think I need to do, is find out how to change the class directly using script so that all the elements are changed immediately without the need for nasty loops.

    Can anybody help me? If this is not possible, I would like to know that too....

    Thanks!

  2. #2
    Fanatic Member punkpie_uk's Avatar
    Join Date
    Sep 2001
    Location
    UK
    Posts
    645
    I doubt this is standard but it works.

    Right,

    1/ Put all stylesheets in external css files.
    2/ In the link tag give it an id

    e.g

    <link id= "stylesheet" href="styles/default.css" rel="stylesheet" type="text/css">


    3/ reference the stylesheet, when you want to change it, using document.getElementById and change the href to the second stylesheet location.

    e.g

    document.getElementById('styleSheet').href = 'styles/default.css';

    This will change all classes contained in that stylesheet.
    SPREAD THE WORD!!! Are You Lee McCormick? Because I Am



    Lee M McCormick
    [email protected]

    Lee McCormick.com - Live
    Dynamically Webbed.com - In development but live

Posting Permissions

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



Click Here to Expand Forum to Full Width