How to show / hide multiple elements at the same time with javascript

Posted by DerNalia on Stack Overflow See other posts from Stack Overflow or by DerNalia
Published on 2010-06-11T14:48:26Z Indexed on 2010/06/11 14:52 UTC
Read the original article Hit count: 257

Filed under:

So, I have this between my head tags

<script type="text/javascript">
hidden_links = document.getElementsByName("javascript_needed");
    for (i = 0; i < hidden_links.length; i++) {
        hidden_links[i].style.display = "visible";
    }
</script>

And my divs are all similar to

    <div name="javascript_needed" style="display: none;">stuff</div>

the overall goal here, is to have these divs hide when javascript is disabled, and re-enable them when javascript is enabled.... but for whatever reason, my code doesn't work. I ever tried it in the webkit console, and nothing errored =\

© Stack Overflow or respective owner

Related posts about JavaScript