首先,在移动版本上的测试结果是,直接使用Target属性来部分代替onclick
使用Target属性:touchEnd --- animationend 46ms
click ---- animationend 37ms
touchEnd --- click 10ms 也有时候6-8ms
使用touchEnd 追加Class:
touchEnd --- animationend 35ms
click ---- animationend 24ms
touchEnd --- click 10ms 也有时候6-8ms
所以总结来看,touchEnd追加Class,比使用Target伪类要快,响应事件要短。
所以说,使用Target来代替click的情况,只适合于在没有JS的情况下使用。也可以做一定的兼容来处理。
个人觉得,还是不使用Target来部分取代 click 比较好。
使用Target属性:touchEnd --- animationend 46ms
click ---- animationend 37ms
touchEnd --- click 10ms 也有时候6-8ms
使用touchEnd 追加Class:
touchEnd --- animationend 35ms
click ---- animationend 24ms
touchEnd --- click 10ms 也有时候6-8ms
所以总结来看,touchEnd追加Class,比使用Target伪类要快,响应事件要短。
所以说,使用Target来代替click的情况,只适合于在没有JS的情况下使用。也可以做一定的兼容来处理。
个人觉得,还是不使用Target来部分取代 click 比较好。
本文通过对比touchEnd与click事件在移动端的表现,得出touchEnd追加Class的方法响应更快的结论,并建议在有JS支持的情况下采用此方法优化用户体验。
1054

被折叠的 条评论
为什么被折叠?



