duanmianzhou5353 2013-05-27 12:56
浏览 37

fancybox无法使用jscarousel 2

i'm having a php code used with jscarousel 2

http://www.egrappler.com/jquery-contentthumbnail-slder-v2-0-jscarousel-v2-0/

to display items from the database as a carousel and having links like this

<a id="addtocart" product="<?php echo $productID; ?>" href="#addDiv" >add</a>

and a hidden div

<div style="display:none">
<div id="addDiv" style="width:300px; height:250px; background-color:#969;">test</div>
</div>

and another link just for testing and it's not inside the carousel just like the previous one

the problem is : links inside the carousel don't show the fancybox while the other link outside the carousel shows the fancybox i've tried this

$(document).ready(function(e) {

$("a#addtocart").fancybox({
        'transitionIn'  : 'elastic',
        'transitionOut' : 'elastic' 
    });
$(document).on("click","a#addtocart",function(){
            $(this).fancybox({
        'transitionIn'  : 'elastic',
        'transitionOut' : 'elastic' 
    });
});
});

any help please ?

  • 写回答

2条回答 默认 最新

  • dongshan9338 2013-05-27 13:06
    关注

    What exactly do you want to do? I think the problem is, you are working with IDs. Maybe you should add the "click" event you are using to a class. Every ID may be in a html document just once, so you can just have one element with the ID addtocart.

    <a href="#addDiv" class="fancybox" product="<?php echo $productID; ?>">add</a>
    

    Try this jQuery:

    $(document).ready(function(e) {
        $("a .fancybox").fancybox({
            'transitionIn'  : 'elastic',
            'transitionOut' : 'elastic' 
        });
    
        $(document).on("click","a .fancybox", function() {
            $(this).fancybox({
                'transitionIn'  : 'elastic',
                'transitionOut' : 'elastic' 
        });
    });
    

    When you use the dot (.) instead of the hashkey (#) you are able to use classes instead of ids.

    If that does not help you, you can find an implementation of jCarousel and Fancybox right here: http://www.mccran.co.uk/examples/jcarousel/

    评论

报告相同问题?

悬赏问题

  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看