Browse - Programming Tips - How do I alternately show and hide an HTML element?

Date: 2014dec6
Library: jQuery

Q.  How do I alternately show and hide an HTML element?

A.  Use jQuery's toggle like this:

<button type=button id=mybutton>Toggle</button> <div id=mything>Hello</div> <script src=jquery.js></script> <script> $('#mybutton').click(function() { $('#mything').toggle(); }); </script>