简体   繁体   English

点击jquery添加类时屏幕闪烁

[英]Screen flash when adding class on click jquery

I added a click event to some pricing tables so they apply animation class for mobile devices. 我在某些价格表中添加了click事件,因此它们将动画类应用于移动设备。 It works but everytime I am on iphone and I click pricing option it flashes the screen before it applies the class, is there a way to get rid of this? 它可以工作,但是每次我在iphone上单击价格选项时,在应用课程之前,屏幕都会闪烁,是否有办法消除这种情况?

To see flash please view on iphone or mobile device located here: http://codepen.io/bskousen/pen/ijqBo 要查看闪光灯,请在以下位置的iPhone或移动设备上查看: http : //codepen.io/bskousen/pen/ijqBo

Your code makes no sense 您的代码没有意义

$(".box").click(function(){
   $(this).parent().addClass("circle");

  }).click(function(){
       $(this).parent().removeClass("circle");
});

You are basically doing this 你基本上是在做这个

$(".box").click(function(){
   $(this).parent().addClass("circle");
   $(this).parent().removeClass("circle");
});

If you want to toggle a class with multiple clicks, you should use toggleClass() 如果要单击多次来切换类,则应使用toggleClass()

$(".box").click(function(){
   $(this).parent().toggleClass("circle");
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM