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

    Styling Markup on the fly

    Hi,

    I'm creating an H3 element with script like so:

    var equip_span = document.createElement("h3");
    equip_span.setAttribute("class", "title_equip");

    Then in the css I'm styling like this:

    h3.title_equip {
    font-weight:bold;
    font-size:1em;
    }

    This works great in Firefox but for some reason IE6 does not style the H3. If I change the attribute from "class" to "id" and then style with h3#title_equip, it DOES work in IE.

    But, this H3 element is not unique and is created a number of times, so I want it to be a class rather than id. Any ideas why IE is not recognizing the class?

    Thanks in advance,
    JonathanSF

  • #2
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    You need to use className and IE sometimes doesn't like it when you use setAttribute for certain attributes so I recommend the DOM1 method.
    Code:
    var equip_span = document.createElement("h3");
    equip_span.className = "title_equip";
    Last edited by _Aerospace_Eng_; 07-13-2006 at 08:14 PM.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #3
    New to the CF scene
    Join Date
    May 2006
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts
    That's It!

    Thank You!


  •  

    Posting Permissions

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