J’ai créé un diaporama simple mais cela ne fonctionne pas. J’ai utilisé function et setInterval mais je ne vois toujours aucun effet. aussi toute erreur sur le sélecteur css
function slideshow() { var $active = $('DIV#slider-wrap IMG.active'); var $next = $active.next(); $next.addClass('active'); $active.removeClass('active'); } $(function(){ setInterval("slideshow",5000); });
* { margin:0; padding:0; } #slider-wrap { position:relative; } .slideshow .images { width:100%; max-width:960px; height:350px; overflow:hidden; } .slideshow .images img { position:absolute; width:100%; max-width:960px; height:auto; } .active { z-index:99; }
aide-moi là-dessus
javascript setInterval accepte comme premier argument une fonction et non une chaîne.
function slideshow() { var $active = $('div#slider-wrap img.active'); var $next = $active.next(); $next.addClass('active'); $active.removeClass('active'); } $(function() { setInterval(slideshow, 1000); });
* { margin: 0; padding: 0; } #slider-wrap { position: relative; } .slideshow .images { width: 100%; max-width: 960px; height: 350px; overflow: hidden; } .slideshow .images img { position: absolute; width: 100%; max-width: 960px; height: auto; } .active { z-index: 99; }