jQuery bxSlider 高级配置
我正在尝试使用 jQuery bxSlider 淡入幻灯片上的元素。我试图弄清楚如何使用 currentSlideHtmlObject 来取回动画幻灯片内的 H1。这是我现在的代码。动画在第一张幻灯片上运行,但我无法让它在每个幻灯片过渡上运行。我找到了将 currentSlideHtmlObject 添加到 onAfterSlide: function() 的选项,但不知道如何使用它来定位幻灯片内的每个 h1 。
$(function(){
$(".sliderWrapper li").each(function(index) {
$(this).addClass('slide' + index);
});
$(".sliderWrapper").bxSlider({
mode: 'fade',
speed:500,
pause: 8000,
auto:true,
autoHover: true,
onAfterSlide: function(){
$(".sliderWrapper li h1").each(function(){
$(this).animate({
opacity: 0.4,
fontSize: "3em",
});
});
},
});
});
<ul class="sliderWrapper">
<li><img src="images/jetGuy.png"/>
<h1>professionalism defined.</h1>
<div class="popup">popup</div>
</li>
<li><img src="images/jet.png" />
<h1>professionalism defined.</h1>
<div class="popup">popup</div>
</li>
<li><img src="images/personal.png" />
<h1>professionalism defined.</h1>
<div class="popup">popup</div>
</li>
</ul>
I'm trying to use the jQuery bxSlider to fade in elements on my slides. I'm trying to figure out how i would use currentSlideHtmlObject to get back the H1 inside the slide that animate. Here is my code right now. The animation runs on the first slide, but I can't get it to run on each slide transition. I found the option of currentSlideHtmlObject to add to onAfterSlide: function() but don't know how i would use it to target each h1 inside the slide.
$(function(){
$(".sliderWrapper li").each(function(index) {
$(this).addClass('slide' + index);
});
$(".sliderWrapper").bxSlider({
mode: 'fade',
speed:500,
pause: 8000,
auto:true,
autoHover: true,
onAfterSlide: function(){
$(".sliderWrapper li h1").each(function(){
$(this).animate({
opacity: 0.4,
fontSize: "3em",
});
});
},
});
});
<ul class="sliderWrapper">
<li><img src="images/jetGuy.png"/>
<h1>professionalism defined.</h1>
<div class="popup">popup</div>
</li>
<li><img src="images/jet.png" />
<h1>professionalism defined.</h1>
<div class="popup">popup</div>
</li>
<li><img src="images/personal.png" />
<h1>professionalism defined.</h1>
<div class="popup">popup</div>
</li>
</ul>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用 -
而不是 -
在幻灯片后功能中
。希望有帮助。
use -
Instead of -
in the after slide function.
hope it helps.