零零乙 2015-06-11 18:42 采纳率: 33.3%
浏览 63

jQuery的fancybox不显示

In below code, both buttons are supposed to toggle the pop-up, but only one works.

The first button (SUBMIT) will submit the form but the popup refuses to open

The second button (TEST) doesn't submit the form but the popup shows up

I don't understand why it isn't working. The first button is supposed to submit the form AND open the popup.

<script type="text/javascript" src="https://www.ni-dieu-ni-maitre.com/scripts/jquery.fancybox.js?v=2.1.1"></script>
<link rel="stylesheet" type="text/css" href="https://www.ni-dieu-ni-maitre.com/scripts/jquery.fancybox.css?v=2.1.1" media="screen" />

<script type="text/javascript">
    $(document).ready(function() {
        $('.fancybox').fancybox();

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

        $("#popupajouterpanier").fancybox({
            openEffect: 'elastic',
            openSpeed: 150,
            closeEffect: 'elastic',
            closeSpeed: 150,
            width: 500,
            height: 300,
            scrolling: 'no',
            padding: 15
        });

        $("#popupajouterpanier2").fancybox({
            openEffect: 'elastic',
            openSpeed: 150,
            closeEffect: 'elastic',
            closeSpeed: 150,
            width: 500,
            height: 300,
            scrolling: 'no',
            padding: 15
        });
    });
</script>

</head>

<body>

    <div id="ribbonmenu">
        <div class="ribbon">
            <a href="https://www.ni-dieu-ni-maitre.com/commande.php" rel="nofollow" class="navlink basketUrlHolder" id="navlink">BASKET </a>
            <span class="basket-counter">0</span></a>

        </div>
    </div>

    <script src="https://www.ni-dieu-ni-maitre.com/shop-controller.js"></script>
    <form action="" style="padding: 0px;" method="post" name="tshirt_form" id="tshirt_form" onload="hideProgress()">
        <input type="hidden" name="product" id="productId" value="1000933638" />
        <input type="hidden" name="article" id="articleId" value="16047246" />
        <input type="hidden" name="view" id="currentView16047246" value="351" />
        <input type="hidden" name="color" id="productColor16047246" value="2" />
        <select class="b-core-ui-select__select" id="size" name="size" onchange="redirect(this);">
            <option selected value="3">M</option>
        </select>
        <select class="b-core-ui-select__select" id="quantity" name="quantity">
            <option selected value="1">1</option>
        </select>

        <a style="position:relative;top:10px;" onclick="document.getElementById('loader').style.display='block';hideProgress()" id="popupajouterpanier" href="#inlinepopupajouterpanier">SUBMIT</a>
    </form>

    <a style="position:relative;top:10px;" onclick="document.getElementById('loader').style.display='block';hideProgress()" id="popupajouterpanier2" href="#inlinepopupajouterpanier">TEST</a>

    <div style="display: none;">
        <div id="inlinepopupajouterpanier2" style="width:550px;height:350px;text-align:center;">
            if this popup shows up, then it's working !!!!
        </div>
    </div>
  • 写回答

1条回答 默认 最新

  • weixin_33720078 2015-06-11 18:48
    关注

    The id of the buttons should not be same. I found its "popupajouterpanier". It can only work in case with unique id names.

    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog