This is a discussion on "clear previous show function" within the JavaScript Forum section. This forum, and the thread "clear previous show function are both part of the Program Your Website category.
|
|
|
|
|
![]() |
||
clear previous show function
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
|||
|
clear previous show function
Hi everyone - hoping some can help
Here is my code <script> function show( id ) { if (document.getElementById(id).style.display == 'block') { document.getElementById(id).style.display = 'none'; }else { document.getElementById(id).style.display = 'block'; }; } </script> <span style="cursor:-moz-grab" onclick="show('r1m');">Will it cost me anything to join this site?</span> </strong></div> <div id="r1m" style="Display: None;"> <blockquote>No its free</blockquote> </div> <div id="r2l"><strong> <span style="cursor:-moz-grab" onclick="show('r2m');">Who can join?</span> </strong></div> <div id="r2m" style="Display: None;"> <blockquote>Anyone aged 16 years or older with a mobile phone and access to the Internet can join.</blockquote> </div> As you can see the is from a faq section of code - where you click on the question and the answer is displayed below the question. However once the question is clicked the question remains visible unless you click on the question again. This is fine but what I also want is this - when you click on another question, the previous answer that has been displayed will disappear leaving only the current answer showing. thanks Tim |
|
|
|
|||
|
Re: clear previous show function
Add a global variable to your script, e.g.,
|
![]() |
| Tags |
| show function |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| javascript show/hide function | danny322 | JavaScript Forum | 1 | May 15th, 2008 12:46 |
| all clear ltd | littlebilly | Free Web Site Critique | 9 | Aug 7th, 2007 21:50 |
| How to reload the previous page? | khwab | JavaScript Forum | 1 | Aug 22nd, 2006 10:41 |
| how do I get the previous value | tllcll | JavaScript Forum | 1 | Oct 24th, 2005 11:51 |
| next previous | GillBates | Webforumz Suggestions and Feedback | 4 | Mar 4th, 2004 17:44 |