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

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -