



function slideSwitch() {
var $active = $('#slideshow DIV.active');
if ( $active.length == 0 ) $active = $('#slideshow DIV:last');
// показываем картинки по-очереди, одна за другой
var $next = $active.next().length ? $active.next() : $('#slideshow DIV:first');
// если надо показывать картинки случайным образом, то можно использовать закомментированный код ниже
// 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 ); // задержка 5 секунд
});<div id="slideshow">
<div class="active">контент 1</div>
<div>контент 2</div>
..................................
<div>контент n</div>
</div>
#slideshow { position:relative; height:400px; }
#slideshow DIV { position:absolute; top:0; left:0; z-index:8; opacity:0.0; height: 400px; background-color: #FFF; }
#slideshow DIV.active { z-index:10; opacity:1.0; }
#slideshow DIV.last-active { z-index:9; }function slideSwitch() {
var $active = $('#slideshow IMG.active');
if ( $active.length == 0 ) $active = $('#slideshow IMG:last');
// показываем картинки по-очереди, одна за другой
var $next = $active.next().length ? $active.next() : $('#slideshow IMG:first');
// если надо показывать картинки случайным образом, то можно использовать закомментированный код ниже
// 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 ); // задержка 5 секунд
});<div id="slideshow">
<img src="image_1.jpg" alt="Slideshow Image 1" class="active" />
<img src="image_2.jpg" alt="Slideshow Image 2" />
...............................................
<img src="image_n.jpg" alt="Slideshow Image n" />
</div>#slideshow { position:relative; height:350px; }
#slideshow IMG { position:absolute; top:0; left:0; z-index:8; opacity:0.0; }
#slideshow IMG.active { z-index:10; opacity:1.0; }
#slideshow IMG.last-active { z-index:9; }
Очень часто сталкиваюсь с вопросами реализации связанных динамичных выпадающих списков (select), очень много методов, самых различных, даже JSON в некоторых используется, что на мой скромный взгляд только дублирует данные из базы и создаёт банальную избыточность.
<?php $headerstuff = $this->getHeadData();
$scripts = $headerstuff['scripts'];
$headerstuff['scripts'] = array();
foreach($scripts as $url=>$type) {
if (strpos($url, 'js/mootools.js') === false && strpos($url, 'js/caption.js') === false) {
$headerstuff['scripts'][$url] = $type;
}
}
$this->setHeadData($headerstuff); ?>