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(); }); });
Comments
Post a Comment