gpt4 book ai didi

javascript - 为什么我的 fancybox 无法在 $ ('.selector' ).click() 上打开?

转载 作者:行者123 更新时间:2023-11-28 16:58:55 26 4
gpt4 key购买 nike

我有一个样式链接页面,我使用 jQuery 将其分成几个部分。

  1. 使用 jQuery .internal 会使页面导航到由用户单击的 div 内链接的 href 属性指定的指定目标。
  2. .external.internal 执行相同的操作,只不过它在新选项卡中打开。
  3. .video 应该只是导致单击的 div 播放 fancybox 中链接指定的视频,但事实并非如此。它也不会在控制台中报告错误。

这是我的 fancybox 代码:

HTML

<div id="fentanylVid" class="col-sm-3 dept video" data-department="fentanyl the real deal">
<div class="box listed-left animated-content move_right animate clearfix">
<div class="box-text">
<h4><a data-fancybox="" href="https://youtu.be/Tt0dFCuwkfQ?rel=0">Fentanyl: The Real Deal (Video)</a></h4>
</div>
</div>
</div>

jQuery

$('.video').click(function(){
$().fancybox({
selector : '.video'
});
});

我的页面标题中也有这两个资源

最佳答案

您可以像这样初始化 fancybox

$('.video').fancybox({
selector : '.video'
});

或者正如@Taplar所说

$('.video').click(function(){
$.fancybox.open(this)
});

关于javascript - 为什么我的 fancybox 无法在 $ ('.selector' ).click() 上打开?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58238484/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com