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 2 of 2

Thread: <Span> tag

  1. #1
    Regular Coder
    Join Date
    Sep 2006
    Posts
    216
    Thanks
    9
    Thanked 0 Times in 0 Posts

    <Span> tag

    I have a three <span></span> sections and when each is clicked another section is loaded and another is hid using code similar to below:

    Code:
    document.all.menu0.style.display = 'none';
    document.all.menu2.style.display = 'none'; 
    document.all.menu3.style.display = 'block';
    I have an onload function which hides two of the sections intially BUT all the sections are visible initially for a split second and then disappear as the onload event kicks in. this flash of all the segments is messy. Any ideas on how to prevent this??

    Thanks

  • #2
    Senior Coder
    Join Date
    Aug 2002
    Location
    UK
    Posts
    2,789
    Thanks
    2
    Thanked 14 Times in 14 Posts
    document.all is IE only and you should be using document.getElementById()

    document.getElementById("menu0").style.display = 'none';
    document.getElementById("menu2").style.display = 'none';
    document.getElementById("menu3").style.display = 'block';


    Create style rules to initially set the spans display value to none

    You can create individual rules for each span

    #menu0{
    display:none;
    }

    #menu1{
    display:none;
    }

    #menu2{
    display:none;
    }

    or one for all and add class="hide" to each span

    .hide{
    display:none;
    }
    The silent one.

    The most dangerous thing in the world is an idea.
    The most dangerous person in the world is the one with an idea.


  •  

    Posting Permissions

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