Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/381.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/81.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript jQuery lightbox(featherlight)不使用单击事件_Javascript_Jquery_Lightbox - Fatal编程技术网

Javascript jQuery lightbox(featherlight)不使用单击事件

Javascript jQuery lightbox(featherlight)不使用单击事件,javascript,jquery,lightbox,Javascript,Jquery,Lightbox,我使用的是轻量级jQuery lightbox插件,但我不知道如何使用with click事件加载lightbox,因为我不擅长jQuery代码 以下是我的代码工作: HTML: <a href="#" data-featherlight="#fl1">Load Lightbox</a> <button id="openbox">Load Lightbox on click event</button> <div class="lightb

我使用的是轻量级jQuery lightbox插件,但我不知道如何使用with click事件加载lightbox,因为我不擅长jQuery代码

以下是我的代码工作:

HTML:

<a href="#" data-featherlight="#fl1">Load Lightbox</a>
<button id="openbox">Load Lightbox on click event</button>

<div class="lightbox" id="fl1">
    <h2>Delete Item</h2>
    <div class="row">
        <div class="twelve columns">
            <strong>Are you Sure?</strong>
            <br>blubblub?
        </div>
    </div>
    <div class="right"> <a href="#" class="btn btn_gray no text_none" id="close_button">Close</a>
    <a href="#" class="btn btn_red text_none">Yes</a>
    </div>
</div>
jQuery(document).on("click", "#openbox", function() {
    jQuery('.lightbox').featherlight();
});
JSFiddle:

评论回复:

<a href="#" data-featherlight="#fl1">Load Lightbox</a>
<button id="openbox">Load Lightbox on click event</button>

<div class="lightbox" id="fl1">
    <h2>Delete Item</h2>
    <div class="row">
        <div class="twelve columns">
            <strong>Are you Sure?</strong>
            <br>blubblub?
        </div>
    </div>
    <div class="right"> <a href="#" class="btn btn_gray no text_none" id="close_button">Close</a>
    <a href="#" class="btn btn_red text_none">Yes</a>
    </div>
</div>
jQuery(document).on("click", "#openbox", function() {
    jQuery('.lightbox').featherlight();
});
但是如果我想显示逻辑条件为:

<a href="#" data-featherlight="#fl1">Load Lightbox</a>
<button id="openbox">Load Lightbox on click event</button>

<div class="lightbox" id="fl1">
    <h2>Delete Item</h2>
    <div class="row">
        <div class="twelve columns">
            <strong>Are you Sure?</strong>
            <br>blubblub?
        </div>
    </div>
    <div class="right"> <a href="#" class="btn btn_gray no text_none" id="close_button">Close</a>
    <a href="#" class="btn btn_red text_none">Yes</a>
    </div>
</div>
jQuery(document).on("click", "#openbox", function() {
    jQuery('.lightbox').featherlight();
});
我希望有人能指引我正确的道路

谢谢

     $.featherlight('#fl1');
请注意,灯箱的id为“fl1”

这是小提琴

这里是if-else的例子

如果fiddle链接起作用,@Gowri抱歉,这是我的错误。我正在更新我的JSFIDLE。@Gowri嗨。我更新了小提琴。我想在按钮点击事件上打开lightbox,而不是默认的锚链接。这是我的小提琴链接
http://jsfiddle.net/g68bZ/18/
see here@Mr.Happy check Kartikeya链接正在运行。已将lightbox属性(data featherlight)添加到按钮字段。您提供的答案已在上述评论中的我的小提琴链接中提供。@Kartikeya是的,我看到它太晚了,抱歉!你好我的逻辑中有一些条件,我用不同的灯箱显示逻辑。检查我用粗体文本更新的问题。谢谢。例如,如果
checkedCount==1
display first lightbox和
checkedCount>1
display second lightbox。@Webice感谢您的大力支持。它对我有用:)为你竖起大拇指:)