javascript - How do I make a div hide onclick and make it show when it's clicked again? -
i have code:
<script> (function ($) { $(document).ready(function () { $("#thisclick, #thisclick2").click(function () { if ($('.example').is(":hidden")) { $(this).html($(this).html().replace(/hide/, 'show')); } else { $(this).html($(this).html().replace(/show/, 'hide')); } // afterwards operation async $(".example").hide(); }); }); })(jquery); </script>
the way current code works if #thisclick
clicked hides #example
. require when #thisclick
clicked again want show #example
. using above code, won't work. must achieve this?
you should able change code follows work:
(function ($) { $(document).ready(function() { $("#thisclick").click(function () { $("#example").slidetoggle("slow"); }); }); })(jquery);
here link quick sample: http://jsfiddle.net/andyjmeyers/szmxp/
Comments
Post a Comment