Welcome visitor
* Login
* Register
It is currently January 18th, 2019, 9:54 pm
All times are UTC [ DST ]
* Search
View unanswered posts - View active topics

FORUMS » Client Side » HTML



Post new topic Reply to topic  [ 3 posts ] 
Author Message
  links to hide and/or display sections of a page
PostPosted: November 9th, 2009, 11:14 pm 

Posts: 24
Hello friends, Im developing a website that has a looot of text in some pages. Do you know about an easy way of creating links that would only hide/show content? Nothing fancy, just functional and keeping everything in one page only. Thank you.


Top
 Profile  
 
  Re: links to hide and/or display sections of a page
PostPosted: November 9th, 2009, 11:34 pm 
User avatar

Posts: 42
I hope this bit of HTML and JavaScript is what you need, or at least it can help you. If you need something else, post again!
<head>
<style type="text/css">
  p{display: none}
</style>
<script type="text/javascript">
function showthe(y){
  y=document.getElementById(y);
  if(window.x === undefined){}
  else{x.style.display='none';}
  y.style.display = 'block';
  x = y;
}
</script>
</head>

<body onload="showthe('title');">
<a href="#" onclick="showthe('title');">Title</a>
<a href="#" onclick="showthe('subtitle');">Show subtitle</a>
<a href="#" onclick="showthe('txt1');">First part</a>
<a href="#" onclick="showthe('txt2');">Second part</a>
<p id="title">this goes 1</p>
<p id="subtitle">then</p>
<p id="txt1">text</p>
<p id="txt2">more text</p>


Top
 Profile  
 
  Re: links to hide and/or display sections of a page
PostPosted: November 10th, 2009, 7:28 am 
User avatar

Posts: 136
http://www.scriptingok.com/forum/t12_56-Using-buttons-to-hide-or-show-content


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

FORUMS » Client Side » HTML


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron