Created
April 10, 2014 18:50
-
-
Save dsebao/10411330 to your computer and use it in GitHub Desktop.
Simple Slideimg with jQuery (WP)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="bgslide"> | |
<img src="<?php bloginfo('template_url');?>/images/slide1.png" class="active"> | |
<img src="<?php bloginfo('template_url');?>/images/slide2.png"> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//slidebg | |
function slideSwitch() { | |
var $active = $('.bgslide img.active'); | |
if ( $active.length == 0 ) $active = $('.bgslide img:last'); | |
var $next = $active.next().length ? $active.next() | |
: $('.bgslide img:first'); | |
$active.addClass('last-active').animate({opacity: 0.0}, 1000); | |
$next.css({opacity: 0.0}) | |
.addClass('active') | |
.animate({opacity: 1.0}, 1000, function() { | |
$active.removeClass('active last-active'); | |
}); | |
} | |
$(function() { | |
setInterval( "slideSwitch()", 5000 ); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment