i've googled around , found many scripts hiding , showing div contents, toggle on button click.
but work using id's.
i same thing want use class instead of id if want have 20 div's toggle ... hide / show don't have add code.
here code:
<script language="javascript"> function toggle() { var ele = document.getelementbyid("toggletext"); var text = document.getelementbyid("displaytext"); if(ele.style.display == "block") { ele.style.display = "none"; text.innerhtml = "show"; } else { ele.style.display = "block"; text.innerhtml = "hide"; } } </script> <a id="displaytext" href="javascript:toggle();">show</a> <== click here <div id="toggletext" style="display: none"><h1>peek-a-boo</h1></div>
can please?
thanks
is jquery option? so, because want:
$(".class").toggle(); or $(".class").show(); $(".class").hide();
Comments
Post a Comment