ios不兼容CSS的active属性解决方法

:active伪类是在类似'mousedown'事件触发的时机生效的,而手机上并没有'mousedown'事件,取而代之的只有'touchstart'和'touchend'。
只需要给这个a链接的touch系列的任意事件touchstart/touchend绑定一个空的匿名方法即可hack成功

var a = document.getElementsByTagName('a');
for(var i = 0; i < a.length; i++) {
  a[i].addEventListener('touchstart',function(){},false);
}

添加以上代码,touch按下去后,发现a的active效果生效了

原文地址:https://www.cnblogs.com/lssmd/p/5067305.html