我正在尝试在元素上操作切换类,但不能使用切换类工具,因为脚本正在运行其他函数并且正在对类名进行操作。因此我使用removeClass / addClass。由于某种原因,我无法让它工作。请在下面找到我的脚本;
$(".view-followers").click(function(){
alert("off");
$(this).removeClass("view-followers");
$(this).addClass("view-followers-on");
});
$(".view-followers-on").click(function(){
alert("on");
$(this).removeClass("view-followers-on");
$(this).addClass("view-followers");
});
或者您可以在 jsFiddle 上查看; http://jsfiddle.net/dannyj6/UGBda/
感谢您提供任何帮助