jquery - Not able to remove the class using `queue` -


i adding class name , removing on click on link. can able add class, not able remove class using queue.

here function, 1 fix this?

element.find('a.menu') .click(function () {     flag = !flag;      var spans = element.find('nav span').find('a');      if(flag) {         element.find('nav').addclass('active');         spans.each(function (i) {             $(this).delay(i*100).queue(function(next) {                 $(this).addclass('show').next(); //works             });         });     }      if(!flag) {         $(spans).each(function (i) {             $(this).delay(i*500).queue(function(next) {                 $(this).removeclass('show'); //not working                 next();             })         })     }  }) 

i updated code next , dequeue method added. works.

element.find('a.menu')                     .click(function () {                         flag = !flag;                          var spans = element.find('nav span').find('a');                          if(flag == true) {                              element.find('nav').addclass('active');                             spans.each(function (i) {                                 $(this).delay(i*100).queue(function(next) {                                     $(this).addclass('show');                                     next();                                 });                             });                              return false;                         }                          if(flag == false) {                              $(element.find('nav span').find('a').get().reverse())                             .each(function (i) {                                 $(this).delay(i*100).queue(function() {                                     $(this).removeclass('show').dequeue();                                 });                                 if(spans.length-1 == i) {                                     element.find('nav').delay(i*120).queue(function () {                                         $(this).removeclass('active').dequeue();                                     })                                 }                             })                          }                 }) 

Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -