Jquery花式盒子不在div上工作

时间:2014-03-11 16:33:04

标签: jquery fancybox

我有html源代码

<div class="widget-container">
    <ul class="lazyest_random_list">
        <li class="lazyest_random" id="random_0" style="">
            <div class="lg_thumb">
                <div class="lg_thumb_image">
                    <a id="lg_thumb_onclick_pooja-gupta-hot-2-jpg_4763" href="http://test.com/20%282%29.jpg" class="thickbox" rel="pooja-gupta-hot" ">
                        <img class="thumb" src="http://test.com/thumb/20%282%29.jpg" ">
                    </a>
                </div>
            </div>
        </li>
        <li class="lazyest_random" id="random_1" style="">
            <div class="lg_thumb">
                <div class="lg_thumb_image">
                    <a id="lg_thumb_onclick_andria-dsouza6-jpg_4763" href="http://test.com%286%29.jpg" class="thickbox" rel="andria-dsouza" ">
                        <img class="thumb" src="http://test.com/thumb/%286%29.jpg" ">
                    </a>
                </div>
            </div>
        </li>
    </ul>
</div>

我正在尝试应用jquery fancybox,但这不起作用。

$(document).ready(function() {
    /* Apply fancybox to multiple items */
    $("#widget-container .a").fancybox({
        'transitionIn'  :   'elastic',
        'transitionOut' :   'elastic',
        'speedIn'       :   600, 
        'speedOut'      :   200, 
        'overlayShow'   :   false
    });
});

任何投入此工作的输入

1 个答案:

答案 0 :(得分:1)

widget-container是容器的类,而不是id。此外,据我所知,其中没有类名为a的元素,我认为您的意思是定位标记名 a

$(document).ready(function() {
    /* Apply fancybox to multiple items */
    $(".widget-container a").fancybox({
        'transitionIn'  :   'elastic',
        'transitionOut' :   'elastic',
        'speedIn'       :   600, 
        'speedOut'      :   200, 
        'overlayShow'   :   false
    });
});