Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jquery Slideshow Not working

i have create a simple slideshow but its not working. i have used function and setInterval but still cant see any effect. also any mistake on css selector

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;
	  	}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<div id="slider-wrap">
      <div class="slideshow">
      	   <div class="images">
				<img src="http://tympanus.net/Tutorials/FullscreenSlitSlider/images/1.jpg" alt="" class="active">
				<img src="http://tympanus.net/Tutorials/FullscreenSlitSlider/images/2.jpg" alt="">
				<img src="http://tympanus.net/Tutorials/FullscreenSlitSlider/images/3.jpg" alt="">
				<img src="http://tympanus.net/Tutorials/FullscreenSlitSlider/images/4.jpg" alt="">
      	   </div>
      </div>	
  </div>

help me out on this

like image 211
Kash Avatar asked Dec 18 '25 06:12

Kash


1 Answers

javascript setInterval accepts as first argument a function and not a string.

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;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<div id="slider-wrap">
  <div class="slideshow">
    <div class="images">
      <img src="http://tympanus.net/Tutorials/FullscreenSlitSlider/images/1.jpg" alt="" class="active">
      <img src="http://tympanus.net/Tutorials/FullscreenSlitSlider/images/2.jpg" alt="">
      <img src="http://tympanus.net/Tutorials/FullscreenSlitSlider/images/3.jpg" alt="">
      <img src="http://tympanus.net/Tutorials/FullscreenSlitSlider/images/4.jpg" alt="">
    </div>
  </div>
</div>
like image 149
Alex Char Avatar answered Dec 20 '25 19:12

Alex Char



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!