如何防止手机中的默认事件?eventDefault没有工作吗?请做铬试验,做铬试验
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Document</title>
<script src="http://code.jquery.com/jquery-1.8.3.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquerymobile/1.4.5/jquery.mobile.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1.0,user-scalable=no" />
<style type="text/css">
div img {
-webkit-touch-callout: none;
-webkit-user-select: none;
}
</style>
</head>
<body data-role="page">
<p>this is test</p>
<div>
<img src="http://www.w3school.com.cn/i/eg_tulip.jpg">
</div>
<div>
<img src="http://www.w3school.com.cn/i/eg_tulip.jpg">
</div>
<script type="text/javascript">
$("div img").on("taphold", function(event) {
console.log("11333333");
event.preventDefault();
return false;
});
</script>
</body>
</html>
发布于 2015-09-15 09:30:34
您可以在css中使用pointer-events: none;:
div img {
pointer-events: none;
}该元素从来不是鼠标事件的目标;但是,如果这些后代将指针事件设置为其他值,则鼠标事件可能以其后代元素为目标。 指针- events属性允许控制HTML元素如何响应鼠标/触摸事件--包括CSS悬停/活动状态、单击/点击Javascript中的事件,以及光标是否可见。
https://stackoverflow.com/questions/32581894
复制相似问题