我有一个jQuery函数,其中某些div淡入淡出,我不能将我的整个文件粘贴到jsFiddle中,因为它太大而且所有图像链接都是相对的,但我有以下内容...
// On click hide default, Country specific
$('.default .asia').click(function(){
$('.default').fadeOut("fast");
$(".default").queue(function () {
$('.viewport-asia').fadeIn("fast");
$('.viewport-asia').dequeue();
});
});
$('.default .north-america').click(function(){
$('.default').fadeOut("fast");
$(".default").queue(function () {
$('.viewport-america').fadeIn("fast");
$('.viewport-america').dequeue();
});
});
$('.default .europe').click(function(){
$('.default').fadeOut("fast");
$(".default").queue(function () {
$('.viewport-europe').fadeIn("fast");
$('.viewport-europe').dequeue();
});
});
// Drag event
$(".america-big").draggable();
$(".europe-big").draggable();
$(".asia-big").draggable();
// Reset map
$('a.zoom-out').click(function(){
$('.hidden').fadeOut("fast");
$(".hidden").queue(function () {
$('.default').fadeIn("fast");
$('.hidden').dequeue();
});
})
});
最后一个函数//重置地图“a.zoom-out”应淡出当前div并淡入.default div,它当前淡出当前div但默认div不会淡入? / p>
任何人都可以看到我出错的地方吗?
HTML
<div class="map">
<!-- // Default Map -->
<div class="default">
<div class="asia"><img src="map/asia.png" alt="Asia"></div>
<div class="north-america"><img src="map/north-america.jpg" alt="America"></div>
<div class="europe"><img src="map/europe.jpg" alt="Europe"></div>
</div>
<!-- // Animated Map // North America -->
<div class="viewport-america hidden">
<div class="compass">
<a href="#" class="arrow top">Top</a>
<a href="#" class="arrow right">Right</a>
<a href="#" class="arrow bottom">Bottom</a>
<a href="#" class="arrow left">Left</a>
</div>
<a href="#" class="zoom-out">Zoom Out</a>
<div class="instructions"><img src="map/instructions.png" alt="Instructions"></div>
<div class="america-big"><img src="http://placekitten.com/1989/996" alt="America" /></div>
</div>
<!-- // Animated Map // Europe -->
<div class="viewport-europe hidden">
<div class="compass">
<a href="#" class="arrow top">Top</a>
<a href="#" class="arrow right">Right</a>
<a href="#" class="arrow bottom">Bottom</a>
<a href="#" class="arrow left">Left</a>
</div>
<a href="#" class="zoom-out">Zoom Out</a>
<div class="instructions"><img src="map/instructions.png" alt="Instructions"></div>
<div class="europe-big"><img src="http://placekitten.com/2000/1000" alt="Europe" /></div>
</div>
<!-- // Animated Map // Asia -->
<div class="viewport-asia hidden">
<div class="compass">
<a href="#" class="arrow top">Top</a>
<a href="#" class="arrow right">Right</a>
<a href="#" class="arrow bottom">Bottom</a>
<a href="#" class="arrow left">Left</a>
</div>
<a href="#" class="zoom-out">Zoom Out</a>
<div class="instructions"><img src="map/instructions.png" alt="Instructions"></div>
<div class="asia-big"><img src="http://placekitten.com/1999/999" alt="Asia" /></div>
</div>
</div>
答案 0 :(得分:2)
您不需要queue
功能。
如果您希望同时fadeIn
和fadeOut
:
$('.default .asia').click(function(){
$('.default').fadeOut("fast");
$('.viewport-asia').fadeIn("fast");
});
如果您希望fadeOut
首先完成fadeIn
:
$('.default .asia').click(function(){
$('.default').fadeOut("fast", function(){
$('.viewport-asia').fadeIn("fast");
});
});