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!