I need to build a page that has several links in a list on the page. When someone clicks on one of the links, text would slide out from under the link. I have started something but I am not able to get the old text to go away when someone clicks the new text. So, for example, if someone clicked link 1, text would slide out. Then if they clicked link 2, new text should slide out. The problem is, I can get the text from link 1 to automatically go away when someone clicks on link 2.
Here is the code I have so far. Any help I could get would be greatly appreciated!
<body>
<script type=”text/javascript”>
<!–
function toggle_visibility(id) {
var e = document.getElementById(id);
if(e.style.display == ‘block’)
e.style.display = ‘none’;
else
e.style.display = ‘block’;
}
//–>
</script>
<a href=”#” onclick=”toggle_visibility(‘one’);”>Link one</a><br />
<a href=”#” onclick=”toggle_visibility(‘two’);”>Link two</a><br />
<a href=”#” onclick=”toggle_visibility(‘three’);”>Link three</a><br />
<div id=”one” style=”display:none;”>This is one</div>
<div id=”two” style=”display:none;”>This is two</div>
<div id=”three” style=”display:none;”>This is three</div>
</body>
</html>