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 4 of 4
  1. #1
    Senior Coder Mhtml's Avatar
    Join Date
    Jun 2002
    Location
    Sydney, Australia
    Posts
    3,531
    Thanks
    0
    Thanked 1 Time in 1 Post

    Changing child node styles.

    How can I change the style on child nodes? I always get errors in IE saying it's null or not an object when I do something like this:

    Code:
    var menu = document.getElementById("menu");
    var menuchild = menu.firstChild;
    menuchild.style.display='none';
    Omnis mico antequam dominus Spookster!

  • #2
    jkd
    jkd is offline
    Senior Coder jkd's Avatar
    Join Date
    May 2002
    Location
    metro DC
    Posts
    3,163
    Thanks
    1
    Thanked 18 Times in 18 Posts
    firstChild probably is referring to a TextNode. Make sure the nodeType == Node.ELEMENT_NODE (firstChild.nodeType == 1)

  • #3
    Senior Coder Mhtml's Avatar
    Join Date
    Jun 2002
    Location
    Sydney, Australia
    Posts
    3,531
    Thanks
    0
    Thanked 1 Time in 1 Post
    Thankyou Jkd, I'll have a little play around with that an see if I can get it to work.
    Omnis mico antequam dominus Spookster!

  • #4
    Senior Coder Mhtml's Avatar
    Join Date
    Jun 2002
    Location
    Sydney, Australia
    Posts
    3,531
    Thanks
    0
    Thanked 1 Time in 1 Post
    W00t! DOM rules, I've got my menu going great.. Just to add a few more features.
    Omnis mico antequam dominus Spookster!


  •  

    Posting Permissions

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