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 Coder
    Join Date
    Dec 2005
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    i can't hide my div?

    hi friends h r u?
    i have problem please if any body can solve
    --------------------------------------
    <div1></div>
    <div2>i want to hide this div</div>


    document.getElementById("div1").innerHTML= "document.getElementById('div2').style.display = 'none'";


    while displaying some text in div1 how can i hide div2
    ---------------------------------------

    thanx in advance.

  • #2
    Regular Coder
    Join Date
    Oct 2006
    Posts
    206
    Thanks
    1
    Thanked 0 Times in 0 Posts
    If you want to differentiate between individual divs, you should do this:

    Code:
    <div id="1"></div>
    <div id="2">I want to hide this div</div>
    <div1> and <div2> are not valid HTML.

    To remove div#2 (CSS term for the div with id '2') from the document flow, use this JavaScript code:

    Code:
    document.getElementById('2').style.display = 'none'; //(it can be restored with 'block' instead of 'none')
    If you want to merely make it invisible, but retain a position in document flow (thereby displacing surrounding elements as if it were visible), use this:

    Code:
    document.getElementById('2').style.visibility = 'hidden';
    1212jtraceur
    Last edited by 1212jtraceur; 12-08-2006 at 06:47 PM. Reason: spelling

  • #3
    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
    Unfortunately in the example above the IDs are invalid. IDs can't begin with a number or any special characters.
    ||||If you are getting paid to do a job, don't ask for help on it!||||


  •  

    Posting Permissions

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