Javascript tab,why the code doesn't work?

<script type="text/javascript">
    function clicker(){
        var lier=document.getElementsByTagName("li");
        var diver=document.getElementsByClassName("web_index").getElementsByTagName("div");

        for(var i=0;i<lier.length;i++){
            for(j=0;j<diver.length;j++){
                if(i==j)
                    diver[j].style.display=block;
                }else{
                    diver[j].style.display=none;
                }   
            }
        }
    }   
</script>

</head>

<body >
<ul>
    <li onclick="clicker()" class="li01">one</li>
    <li onclick="clicker()" class="li02">two</li>
    <li onclick="clicker()" class="li03">three</li>
    <div class="web_clear"></div>
</ul>
<div class="web_index">
<div style="display:block" >content one</div>
<div style="display:none">content two</div>
<div style="display:none">content three</div>
</div>

i am a learner of javascript. so first i don’t want to use jquery to get the tab. the above is my code. but it doesn’t work.how to correct my code. thank you.
i want to when click one then show content one.all the content are hidden. two then show content two…

The standard technique for that is for the script to first hide all of the content, and to then show the one that the clicked link refers to.

Typically the second part is achieved by having a link that goes to a fragment identifier, such as “#content1” and to have a div with the same value as its identifier: id=“content1”

i am sorry, i don’t follow the second part and don’t know how to do?thank u

It’s where you have a link, and you have some content. The link uses a fragment identifier, which targets the identifier of the content.


<a href="#content1">Link to content 1</a>
...
<div id="content1">Content 1 is in here</div>

how you will use the fragment identifier, thank you , the more detail is better,

The fragment identifier is the hash symbol followed by some text. For example: #content1
More detail can be found at http://en.wikipedia.org/wiki/Fragment_identifier

But basically, it’s how you tell the web browser that you want to scroll the page down to the part of the page that has that identifier.

How it can be used with scripting, it to disable the default web browser behaviour, and to instead use the fragment identifier from the link as a way to identify the area of interest, in this case that would be showing the related content area, after first hiding them all.