移动端Safari onclick事件兼容

在移动端开发中,当你想进行点击事件委托时,你会发现在safari根本不起作用,这是Safari浏览器的引擎不同吧。有兴趣可以看看这边文章《click delegation on the iPhone》

解决方法1:在其他元素(这元素没有事件)添加点击事件。e.g

document.onclick = function () {
	var newDiv = document.createElement('div');
	// populate div
	newDiv.onclick = function () {};
	document.body.appendChild(newDiv);
}
div.onclick = function () {}
解决方法2:在其他元素(这元素没有事件)添加pointer ccs样式,。e.g
div{
cursor: pointer;
}
原文地址:https://www.cnblogs.com/Ushadow/p/7068730.html