FancyBox not working at all

六眼飞鱼酱① 提交于 2020-01-15 09:06:19

问题


I'm having issues getting fancybox to run - I am running a few other jquery's too. Below are the scripts that are running.

    <!-- latest jQuery direct from google's CDN -->
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js">
</script>

<!-- the mousewheel plugin - optional to provide mousewheel support -->
<script type="text/javascript" src="../js/jquery.mousewheel.js"></script>

<!-- the jScrollPane script -->
<script type="text/javascript" src="../js/jquery.jscrollpane.min.js"></script>

<!-- EasySlider -->
<script type="text/javascript" src="../js/easySlider.js"></script>

<!-- fancybox -->
<script type="text/javascript" src="../js/fancybox/jquery.fancybox-1.3.2.pack.js"></script>

<!-- fancybox transitions -->
<script type="text/javascript" src="../js/fancybox/jquery.easing-1.3.pack.js"></script>

<script>
$(function()
{
    $('.scroll-pane').jScrollPane();
});

</script>  

<script>
$(document).ready(function(){   
    $("#slider").easySlider({
        auto: true,
        continuous: true 
    });
});

</script> 

<script>
$(document).ready(function(){   
    $("a#fancy").fancybox({
        'transitionIn'  :   'elastic',
        'transitionOut' :   'elastic',
        'speedIn'       :   600, 
        'speedOut'      :   200, 
        'overlayShow'   :   false
    });


});
</script>

And this is the div that's currently (not) being affected.

<div class="bodytext" style="position:absolute; left:457px; top:911px; width:468px; height:23px;">
<a id="a#fancy" href="../katie/studies/1_explorer/explorer_01.png">1</a>
&bull; 
<a id="a#fancy" href="../katie/studies/1_explorer/explorer_02.jpg">2</a>
&bull; 
<a id="a#fancy" href="../katie/studies/1_explorer/explorer_03.jpg">3</a>
</div>

Not sure what's going on as all the other scripts are running fine. Cheers for any help. It's probably something simple that I'm overlooking :]


回答1:


$(document).ready(function(){   
    $("a#fancy").fancybox({
        'transitionIn'  :   'elastic',
        'transitionOut' :   'elastic',
        'speedIn'       :   600, 
        'speedOut'      :   200, 
        'overlayShow'   :   false
    });


});

this is refering to a element with ID 'fancy', not 'a#fancy'. So you could change the ID of your 'a' tag or use the 'a' tag class instead of the id as shown below.

$(document).ready(function(){   
    $("a.fancy").fancybox({
        'transitionIn'  :   'elastic',
        'transitionOut' :   'elastic',
        'speedIn'       :   600, 
        'speedOut'      :   200, 
        'overlayShow'   :   false
    });
});

and html

<div class="bodytext" style="position:absolute; left:457px; top:911px; width:468px; height:23px;">
<a class="fancy" href="../katie/studies/1_explorer/explorer_01.png">1</a>
&bull; 
<a class="fancy" href="../katie/studies/1_explorer/explorer_02.jpg">2</a>
&bull; 
<a class="fancy" href="../katie/studies/1_explorer/explorer_03.jpg">3</a>
</div>



回答2:


a refers to the html tag where fancy is the actual tag of the element that you are trying to select.



来源:https://stackoverflow.com/questions/4077538/fancybox-not-working-at-all

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!