toggle - JQuery: delay a toggleClass just when is adding -


i built code change div.mybutton when click on it. code wants allow .toggleclass() on red-text class in #bar condition .toggleclass() must delayed just when it's removing class.

my code changes mybutton class mybutton2, , adds black-text class #bar. can't second part: .removeclass() delay.

here's code

 $(function () {         $('div.mybutton').click(function () {             $(this).toggleclass('mybutton2');             $('#bar').addclass("black-text");             $(this).removeclass('mybutton').addclass('mybutton2');         });         $('div.mybutton2').click(function () {             $('#bar').delay(1000).queue(function (next) {                 $(this).removeclass("black-text");                 next();             });         });  }); 

and here's jsfiddle demo http://jsfiddle.net/jmarti/gc5xt/2/


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -