我向一些定价表添加了点击事件,以便它们为移动设备应用动画类。它有效,但每次我在 iphone 上单击定价选项时,它都会在应用类(class)之前闪烁屏幕,有没有办法摆脱它?
要查看 Flash,请在位于此处的 iphone 或移动设备上查看:http://codepen.io/bskousen/pen/ijqBo
最佳答案
你的代码没有意义
$(".box").click(function(){
$(this).parent().addClass("circle");
}).click(function(){
$(this).parent().removeClass("circle");
});
你基本上是这样做的
$(".box").click(function(){
$(this).parent().addClass("circle");
$(this).parent().removeClass("circle");
});
如果你想通过多次点击切换一个类,你应该使用toggleClass()
$(".box").click(function(){
$(this).parent().toggleClass("circle");
});
关于javascript - 单击 jquery 添加类时屏幕闪烁,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21313373/