Change the position of div through the javascript

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pankajprakash
    New Member
    • Feb 2007
    • 70

    Change the position of div through the javascript

    I have a two div controls. In a condition I show the first div and hide the second div. When I hide the first div and show the second div, the second div does not change the location. How can I change the second div position to first div.

    Code:
    if(value===1)
    {
    document.getElementById("div1").style.visibility = 'hidden';
    document.getElementById("div2").style.visibility = 'visible';
    }
    else
    {
    document.getElementById("div1").style.visibility = 'visible';
    document.getElementById("div2").style.visibility = 'hidden';
    }
    Need to show the div2 at the position of div1.
    Last edited by Dormilich; Aug 12 '10, 07:32 AM. Reason: Please use [code] tags when posting code
  • pankajprakash
    New Member
    • Feb 2007
    • 70

    #2
    Got the solution

    Code:
    if(value===1)
    {
    document.getElementById("div2").style.display = '';
    document.getElementById("div1").style.display = 'none';
    document.getElementById("div2").style.visibility = 'visible';
    
    }
    else
    {
    document.getElementById("div1").style.display='';
    document.getElementById("div1").style.visibility = 'visible';
    document.getElementById("div2").style.display = 'none';
    }
    Last edited by Dormilich; Aug 12 '10, 07:32 AM. Reason: Please use [code] tags when posting code

    Comment

    Working...