我有幻灯片,它只是改变照片。现在我需要在每张照片的顶部添加一个新的不同div框。目前jquery代码只需#slideshow和.active。如何修改它以获取新的不同“.newbox”(第一张照片为.newbox1,第二张为.newbox2等)。这是我的照片幻灯片jquery代码:
function slideSwitch() {
var $active = $('#slideshow DIV.active');
if ( $active.length == 0 ) $active = $('#slideshow DIV:last');
// use this to pull the divs in the order they appear in the markup
var $next = $active.next().length ? $active.next()
: $('#slideshow DIV:first');
// uncomment below to pull the divs randomly
// var $sibs = $active.siblings();
// var rndNum = Math.floor(Math.random() * $sibs.length );
// var $next = $( $sibs[ rndNum ] );
$active.addClass('last-active');
$next.css({opacity: 0.0})
.addClass('active')
.animate({opacity: 1.0}, 1000, function() {
$active.removeClass('active last-active');
});
}
$(function() {
setInterval( "slideSwitch()", 5000 );
});
</script>
我的HTML:
div id="slideshow">
<div class="active">
<a href="http://www.mylink.com/" target="_blank"><img src="http://route/img.jpg" alt="alt" /></a>
<div class="newbox"><h4><a href="/href">WTF?!</a></h4><p>something</p><a class="bttn action" href="/shop/what-the-at-taz">Buy Now</a> <a class="bttn" href="/shop/explore?designer=211">See More</a></div>
</div>
答案 0 :(得分:0)
使用$active.children('.newbox').text('write your text here');