gpt4 book ai didi

jQuery 自定义 slider 查询

转载 作者:行者123 更新时间:2023-12-01 04:58:46 26 4
gpt4 key购买 nike

这个网站的某人帮助我解决了我遇到的 slider 问题,我只需要有人帮助我解决最后一 block 拼图。

这是 fiddle http://jsfiddle.net/gajjuthechamp/vrqdh/2/

当您点击“缩略图”时,内容会显示在上面的主 div 中。

我需要“extraContent”下的 div/缩略图在“mainContent”下有自己独特的内容 div。

希望这是有道理的。

谢谢

jQuery:

$(function(){
$("#parent").on("click", ".extraContent div", function(){
newHtml=$(this).html();
$("#parent").find(".mainContent p").fadeOut(1000,function(){
$(this).parent().html(newHtml);
$(this).parent().fadeIn(1000);
});
});
});

HTML:

<div id="parent">
<div class="mainContent"> <p>This is the default Text</p></div>
<div class="extraContent">
<div><p>test and Image Goes hear for 1 div</p></div>
<div><p>test and Image Goes hear for 2 div</p></div>
<div><p>test and Image Goes hear for 3 div</p></div>
<div><p>test and Image Goes hear for 4 div</p></div>
</div>
</div>

CSS:

#parent { width:400px; margin:auto}
.mainContent { width:430px; height:300px; border:1px solid #000;padding:5px; }
.extraContent {overflow:auto; width:450px;}
.extraContent div{float:left; width:90px; height:90px; border:1px solid #00F; margin:5px; padding:5px }
.extraContent div:hover { border:1px solid #0F0;cursor:pointer }

最佳答案

jsFiddle demo

HTML:

<div id="parent">
<div class="mainContent">
<div class="cont"> Content 1....</div>
<div class="cont"> Content 2....</div>
<div class="cont"> Content 3....</div>
<div class="cont"> Content 4....</div>
</div>
<div class="extraContent">
<div><p>1 Custom content here</p></div>
<div><p>2 Custom content here</p></div>
<div><p>3 Custom content here</p></div>
<div><p>4 Custom content here</p></div>
</div>
</div>

添加CSS:

.cont{position:absolute;}

jQuery:

$(function(){
$('.cont:gt(0)').hide();
$("#parent").on("click", ".extraContent div", function(){
var ind = $(this).index();
$("#parent").find(".cont").stop().fadeTo(600,0,function(){
$('#parent').find('.cont').eq(ind).stop().fadeTo(300,1);
});
});
});

关于jQuery 自定义 slider 查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12206061/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com