理想情况下,您将编辑库以将当前索引传回给 after 函数。尽管如此,如果您想要快速修复/破解:
你可以这样做:
在这里看到jsfiddle:
http://jsfiddle.net/L5T6Y/1/
使用这样的示例 html:
<div id="slide_content_body">
<div id="slide_content_0" class="slide_content">
<h2>Superfood Smoothies! 1</h2>
</div>
<div id="slide_content_1" class="slide_content" style="display: none;">
<h2>Superfood Smoothies! 2 </h2>
</div>
<div id="slide_content_2" class="slide_content" style="display: none;">
<h2>Superfood Smoothies! 3</h2>
</div>
</div>
<div class="rslides_container">
<ul class="rslides" id="slider1">
<li>
<img src="http://viljamis.com/responsive-slides/1.jpg" alt="" />
</li>
<li>
<img src="http://viljamis.com/responsive-slides/2.jpg" alt="" />
</li>
<li>
<img src="http://viljamis.com/responsive-slides/3.jpg" alt="" />
</li>
</ul>
</div>
js:
$(function () {
// Slideshow 1
var boo = $("#slider1").responsiveSlides({
auto: false,
pager: true,
nav: true,
speed: 500,
maxwidth: 800,
before: function () {
}, // Function: Before callback
after: function () {
$( '.slide_content' ).hide();
$( '#slide_content_' + $('.rslides1_on').index() ).show();
} // Function: After callback
});
});
RE 如果你想在 li 中包含内容,你可以这样做:
看看这个小提琴:http: //jsfiddle.net/dnAC2/2/
更改 js 函数以执行以下操作:
$('#slide_content_panel').html( $('.rslides1_on .content').html() );
至于 html,它看起来像这样:
<div id="slide_content_panel">
</div>
<div class="rslides_container">
<ul class="rslides" id="slider1">
<li>
<img src="http://viljamis.com/responsive-slides/1.jpg" alt="" />
<div class="content" style="display: none;">
<h2>Superfood Smoothies! 1</h2>
</div>
</li>
<li>
<img src="http://viljamis.com/responsive-slides/2.jpg" alt="" />
<div class="content" style="display: none;">
<h2>Superfood Smoothies! 2</h2>
</div>
</li>
<li>
<img src="http://viljamis.com/responsive-slides/3.jpg" alt="" />
<div class="content" style="display: none;">
<h2>Superfood Smoothies! 3</h2>
</div>
</li>
</ul>
</div>