0

We all know jQuery removed toggle(handler, handler[, handler]) since jQuery 1.9. However, I found it really inconvenient if I want to achieve this:

var count = 0;
$('ele').click(function() {
 if(count === 0) { 
  alert("count is 0");
  count += 1;
 }else {
  alert("count is NOT 0")
  count = 0;
 }
});

I wonder if there is any more simple way as a substitue for toggle() ? I've looked for an adequate answer for a while but failed...maybe it's because I missed sth. If possible, please tell me the reason why toggle() was deprecated as well. Thanks!

X-sky
  • 47
  • 5
  • Your question is unclear. I am not sure what you want to achieve. For more queries check the above given links, I think one of them would serve to your requirement. – Code_Ninja May 25 '18 at 02:49
  • I found an answer in another question just now! Thanks anyway.. – X-sky May 25 '18 at 04:02

0 Answers0