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
https://forums.phpfreaks.com/topic/265667-click-anywhere-to-hide-text/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.