[英]Remove data-attribute with Jquery on lower resolutions
I want to hide the following data attribute data-snap-ignore="true"
only for resolutions lower than 880px, but I can't find how to do it. 我只想为低于880px的分辨率隐藏以下数据属性
data-snap-ignore="true"
,但找不到解决方法。
The reason to do that, is because snap.js uses the following data to disable the drag event on the content, so I am interested on hide it on lower resolutions (mobiles and tablets users are used to work with drag event). 这样做的原因是因为snap.js使用以下数据来禁用内容上的拖动事件,所以我有兴趣在较低分辨率下隐藏它(手机和平板电脑用户习惯于使用拖动事件)。
HTML WITH DATA: 带有数据的HTML:
<div id="content" class="snap-content" data-snap-ignore="true">
Content of the website
</div>
EDIT: 编辑:
The function code: 功能代码:
var target = e.target ? e.target : e.srcElement,
ignoreParent = utils.parentUntil(target, 'data-snap-ignore');
if (ignoreParent) {
utils.dispatchEvent('ignore');
return;
}
As you can see it works with the data-snap-ignore
only, without taking care on true
or false
, so it should be replaced maybe for some kind of white content, maybe? 如您所见,它仅适用于
data-snap-ignore
,而无需注意true
或false
,因此应该将其替换为某种白色内容,也许吗?
You can try to use: 您可以尝试使用:
if($(window).width() < 880) {
$('#content').attr('data-snap-ignore','false');
} else {
$('#content').attr('data-snap-ignore','true');
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.