Jump to content

click anywhere to hide text?


erias

Recommended Posts

hi there, i am fairly new to javascript and to this website.. have used my google skills to find some code on how to "click on a link and text appears" i was luckily, able to find a link which worked like a charm-now all i'm wondering is that since for my own website i listed down several links i would like to make sure that once the text appears when being clicked by a link, that it hides when you click anywhere/another link. is this possible? here is the code, got it from http://www.ozzu.com/programming-forum/show-hide-text-t28623.html

 

thank you for those who reply in advanced-it is appreciated greatly! x

 

<html>
<head>
<title>Untitled</title>
<script language="JavaScript">
function showAndHide(theId)
{
    var el = document.getElementById(theId)
    if (el.style.display=="none")
    {
        el.style.display="block"; //show element
    }
    else
    {
        el.style.display="none"; //hide element
    }
}
</script>
</head>
<body>
<p><a href="#" onClick = showAndHide('Title')>Some Title</a></p>
<div id='Title' style="display:none">
<a href="http://www.blah.com/">01-Intro</a>
</div>
</body>
</html>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.