Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/84.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
Jquery Fancybox 1.3.4内置在按钮上_Jquery_Html_Fancybox - Fatal编程技术网

Jquery Fancybox 1.3.4内置在按钮上

Jquery Fancybox 1.3.4内置在按钮上,jquery,html,fancybox,Jquery,Html,Fancybox,好的。。我有类似的设置: <button id="buynow" disabled>Add to Cart</button> <div style="display:none"> <div id="purchase_popup"> Content within here </div> </div> 添加到购物车 内容在这里 那么我的fancybox代码是: <link rel="s

好的。。我有类似的设置:

<button id="buynow" disabled>Add to Cart</button>

<div style="display:none">
    <div id="purchase_popup">
        Content within here
    </div>
</div>
添加到购物车
内容在这里
那么我的fancybox代码是:

<link rel="stylesheet" type="text/css" href="includes/js/jquery.fancybox-1.3.1.css" />
<script type="text/javascript" src="includes/js/jquery.fancybox-1.3.1.pack.js"></script>
<script type="text/javascript">
    $("#buynow").fancybox({
        'href'              : '#purchase_popup',
        'transitionIn'      : 'fade',
        'transitionOut'     : 'fade',
        'titleShow'         : false
    });
</script>

$(“#立即购买”).fancybox({
“href”:“购买”弹出窗口,
“transitionIn”:“fade”,
“transitionOut”:“fade”,
“标题秀”:错误
});
但是由于一些奇怪的原因,当我点击buynow按钮时,我的purchase\u popup div不会弹出。我已经禁用了它,所以它不会导致一个不同的页面,因为这是我刚刚参与的这个项目中的当前操作。 我不知道fancybox中的“href”是否表示它具有捕捉性,或者这是一种错误的方式

任何帮助都将不胜感激

Disabled elements don't fire mouse events. Most browsers will propagate an event 
originating from the disabled element up the DOM tree, so event handlers 
could be placed on container elements.
Firefox,也许还有其他浏览器,在被禁用的表单字段上禁用DOM事件。
从禁用的表单字段开始的任何事件都将被完全取消,并且不会向上传播DOM树。如果单击“禁用”按钮,则事件源为“禁用”按钮,单击事件将完全清除。
浏览器实际上不知道按钮被点击,也不传递点击事件。这就好像你在点击网页上的一个黑洞

所以,您必须删除按钮的禁用属性,或者另一个解决方法是,您可以放置外部容器,在其上可以单击如下内容:

<div style="display:inline-block; position:relative;">
  <button id="buynow" disabled>Add to Cart</button>
</div>​

添加到购物车
​
一些评论:

1) 。如果您的
按钮
被禁用,则您无法在单击
后触发操作

2) 。您需要将fancybox脚本包装到
.ready()
方法中

3) 。由于您使用的是fancybox v1.3.4和
内联内容,因此需要了解和解决方法

因此,您可以使用以下代码:

$(document).ready(function () {
    $("#buynow").fancybox({
        'href': '#purchase_popup',
        'transitionIn': 'fade',
        'transitionOut': 'fade',
        'titleShow': false,
        // fix for inline nested DIVs
        'onCleanup': function () {
            var myContent = this.href;
            $(myContent).unwrap();
        }
    })
}); // ready
请参见