我觉得我的脚本真的是多余的,可能会写得更好。如果有人能给我一些关于如何更好地实现这一点的提示或想法,我将不胜感激。基本上是一个非常简单的幻灯片。
$('.projectview .designinfo').hide();
$('.projectview .buildinfo').hide();
$('.projectview .launchinfo').hide();
$('.projectview .growinfo').hide();
$('.thumbs ul li.plan').bind('click',
function() {
$('.projectview .designinfo, .projectview .buildinfo, .projectview .launchinfo, .projectview .growinfo').fadeOut();
$('.projectview .planinfo').fadeIn();
});
$('.thumbs ul li.design').bind('click',
function() {
$('.projectview .planinfo, .projectview .buildinfo, .projectview .launchinfo, .projectview .growinfo').fadeOut();
$('.projectview .designinfo').fadeIn();
});
$('.thumbs ul li.build').bind('click',
function() {
$('.projectview .planinfo, .projectview .designinfo, .projectview .launchinfo, .projectview .growinfo').fadeOut();
$('.projectview .buildinfo').fadeIn();
});
$('.thumbs ul li.launch').bind('click',
function() {
$('.projectview .planinfo, .projectview .designinfo, .projectview .buildinfo, .projectview .growinfo').fadeOut();
$('.projectview .launchinfo').fadeIn();
});
$('.thumbs ul li.grow').bind('click',
function() {
$('.projectview .planinfo, .projectview .designinfo, .projectview .buildinfo, .projectview .launchinfo').fadeOut();
$('.projectview .growinfo').fadeIn();
});
这是html
<section class="thumbs">
<ul>
<li class="plan">
<img src="images/new/plan.jpg" alt="plan" class="serviceicon">
</li>
<li class="design">
<img src="images/new/design.jpg" alt="design" class="serviceicon">
</li>
<li class="build">
<img src="images/new/build.jpg" alt="build" class="serviceicon">
</li>
<li class="launch">
<img src="images/new/launch.jpg" alt="launch" class="serviceicon">
</li>
<li class="grow">
<img src="images/new/grow.jpg" alt="grow" class="serviceicon">
</li>
</ul>
</section>
<section class="projectview">
<section class="planinfo"><img src="images/new/planinfo.jpg" alt="blog" class="planinfo"></section>
<section class="designinfo"><img src="images/new/designinfo.jpg" alt="blog" class="designinfo"></section>
<section class="buildinfo"><img src="images/new/buildinfo.jpg" alt="blog" class="buildinfo"></section>
<section class="launchinfo"><img src="images/new/launchinfo.jpg" alt="blog" class="launchinfo"></section>
<section class="growinfo"><img src="images/new/growinfo.jpg" alt="blog" class="growinfo"></section>
</section>