日期:2014-05-17  浏览次数:20623 次

css3 :target 和onclick 的区别
首先,在移动版本上的测试结果是,直接使用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 比较好。