javascript - How do I use JQuery to hide a div on click again? -


code:

<script type="text/javascript"> $(document).ready(function() {     $("#clicker").click(function() {         $(".show_this").show();         e.preventdefault();     }); }); </script> 

using script above able show .show_this on clicking #clicker on clicking #clicker again want hide it. how can tweak code that?

i did research , seemed using e.preventdefault(); able achieve didn't work.

use .toggle() instead.

$(document).ready(function() {     $("#clicker").click(function(e) {         $(".show_this").toggle();         e.preventdefault();     }); }); 

jsfiddle example


Comments

Popular posts from this blog

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

html - How to style widget with post count different than without post count -

url rewriting - How to redirect a http POST with urlrewritefilter -