erias Posted July 14, 2012 Share Posted July 14, 2012 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> Quote Link to comment https://forums.phpfreaks.com/topic/265667-click-anywhere-to-hide-text/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.