【发布时间】:2011-09-05 20:52:04
【问题描述】:
我正在学习如何使用 jquery,但我还没有到可以添加自己的 JavaScript 的阶段。我已经在互联网上搜索了一种将播放/暂停按钮添加到全屏背景幻灯片的方法。下面是幻灯片的 JavaScript。
干杯!
function slideSwitch() {
var $active = $('#slideshow IMG.active');
if ( $active.length == 0 ) $active = $('#slideshow IMG:last');
// use this to pull the images in the order they appear in the markup
//var $next = $active.next().length ? $active.next()
//: $('#slideshow IMG:first');
// uncomment the 3 lines below to pull the images in random order
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: 0.87}, 1000, function() {
$active.removeClass('active last-active');
});
}
$(function() {
setInterval( "slideSwitch()", 5000 );
});
【问题讨论】:
-
Java 不是 JavaScript;而 jQuery 是(一个库)JavaScript。
-
好的,谢谢,只是假设 java 很短!
标签: jquery controls background slideshow fullscreen