-
H5页面点击事件不生效问题如何解决?
1、给需要绑定事件的元素添加一个css cursor: pointer ,事件依然用click事件:
.div{cursor:pointer;}
2、第二种解决方案是JS将click事件替换为touchstart事件(如果要兼容电脑端,就需要两个事件并存),或者click事件与touchstart事件并存:// 替换touchstart $(document).on("touchstart",".farmGoods",function(){ alert('hello world!'); }); // click 与 touchstart 并存 $(document).on("click touchstart",".farmGoods",function(){ alert('hello world!'); });