问题
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>
•
<a id="a#fancy" href="../katie/studies/1_explorer/explorer_02.jpg">2</a>
•
<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>
•
<a class="fancy" href="../katie/studies/1_explorer/explorer_02.jpg">2</a>
•
<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