javascript - class not removing as expected with click counter -
var clickcount = 0; $(".arrowright").click(function () { clickcount++; if (clickcount >= 3) { clickcount = 0; $(".arrowright").removeclass("active"); $(".arrowright").addclass("disable"); } else { $(".arrowright").removeclass("disable"); // line isnt working $(".arrowright").addclass("active"); // works } });
everything works above until 'disable
' class. adds after 3 clicks, idea clicks reset after 3rd well, hints else
, 'active
' gets added correctly (eg. within else after 3rd click resets -- but disable
class not remove!
.disable { pointer-events: none; cursor: default; }
changes required css
remove line css class
pointer-events: none;
so class be
.disable { cursor: default; }
here example jsfiddle https://jsfiddle.net/stt2632m/
Comments
Post a Comment