Showing & Hiding Text with Javascript -


i have javascript code faq page site. so, click on question , answer appears. now, can't figure out when have clicked on 1 question , open, when click on want previous 1 close. basically, there ever 1 open @ time. found similar code, not i'm looking for.

any great, here's code. thanks!!!! kait

<script type="text/javascript"> function unhide(divid) { var item = document.getelementbyid(divid); if (item) { item.classname=(item.classname=='hidden')?'unhidden':'hidden'; } } </script>  <p><a href="javascript:unhide('q1');">here question???</a></p>  <div id="q1" class="hidden"> <p>the answer goes here.</p> </div>  <p><a href="javascript:unhide('q2');">here 2nd question???</a></p>  <div id="q2" class="hidden"> <p>the 2nd answer goes here.</p> </div> 

<script type="text/javascript">     var currentitem;     function unhide(divid) {         if (currentitem) {             currentitem.classname = 'hidden';             currentitem = null;         }         var item = document.getelementbyid(divid);         if (item) {             item.classname = 'unhidden';             currentitem = item;         }     } </script> 

Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -