0

I made a JavaScript function to hide a link on click of button and its work here the function

    <script type="text/javascript">
function toggle() 
{
    var ele = document.getElementById("yui-gen1");
    var text = document.getElementById("windows");
    if(ele.style.display == "block") {
            ele.style.display = "none";
    }
    else {
        ele.style.display = "block";
    }
} 
</script>

But when it hidea the next link replace its place. I want nothing to replace its place, I want its place after the hiding to be just empty. Is there any way to do that?

1
  • Could you include the relevant HTML? Commented Aug 3, 2011 at 10:20

2 Answers 2

3

Assuming I've understood your question correctly, your problem is that display:none causes the affected element to take up no space in the document. What you need is the visibility property, which hides the affected element but keeps it's space in the document:

ele.style.visibility = "hidden";

and

ele.style.visibility = "visible";

should work, instead of display.

Sign up to request clarification or add additional context in comments.

Comments

0

Try setting visibility instead. Visibility will still take up the space that the button occupied, it just won't show it. Display removes it altogether so the space will be taken up by the next element.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.