禁用点击 Light Gallery 中的“.lg-img-wrap”类

问题描述

如何禁用点击 .lg-img-wrap?

我尝试了很多解决方案,但似乎没有一个适用于 lightgallery。

尝试了 1 个

$(".lg-img-wrap").children().unbind('click');

尝试了 2 个

$(".noclick").click(function(e) {
    e.preventDefault();
    e.stopPropagation();
});

尝试了 3 个

pointer-events:none //to a css property

用户点击图像外时,我想防止关闭光库。

当图像比例与屏幕尺寸不同时,会出现黑边。

请查看下面的图片以供参考。

lightbox image

我正在使用的灯光画廊:https://github.com/sachinchoolur/lightGallery

解决方法

closeable: false 添加到您的 lightGallery 初始化中。下面是 their API 描述该功能。

Working Codepen

<html>
<head>
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/lightgallery/1.10.0/css/lightgallery.css" integrity="sha512-I/g40Mx7U2Oepd3iHIpQRqdQGJ3vgdw0ix8LxGxX9zKv1MDizjD6dRcJ3PC1qpyfkj4rikVNcpBKcnmuJWUaTQ==" crossorigin="anonymous" />
  <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js" integrity="sha512-bLT0Qm9VnAYZDflyKcBaQ2gg0hSYNQrJ8RilYldYQ1FxQYoCLtUjuuRuZo+fjqhx/qtq/1itJ0C2ejDxltZVFg==" crossorigin="anonymous"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/lightgallery/1.10.0/js/lightgallery.min.js"></script>
</head>
<div id="lightgallery">
  <a href="https://via.placeholder.com/150">
      <img src="https://via.placeholder.com/150" />
  </a>
</div>

<script type="text/javascript">
    $('#lightgallery').lightGallery({
        closable: false
    }); 
</script>
</html>



,
$(".lg-img-wrap").off("click");

$(".lg-img-wrap").prop("disabled",true);

$('.lg-img-wrap"').click(false);

希望对你有用。干得好。

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...