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
Post a Comment