Reputation: 8001
I have markup that looks like this
<div class="myDiv"><ul>
<li><img src="img1.jpg"/></li>
<li><img src="img1.jpg"/></li>
.
.
.
</ul></div>
I need to convert this html to a slideshow. I am not very good at using javascript or jquery. I just need a something that would enable me to pass the class of the div and then all the images in the lists would be converted to a simple slideshow. Thanks in anticipation
Upvotes: 1
Views: 2213
Reputation: 34107
Hiya please try this demo http://jsfiddle.net/NPcDH/ || http://jsfiddle.net/rQS6h/ perhaps & further from below comments your personal page demo is here - http://jsfiddle.net/2wnws/2/show/
its a simple slideshow using li rest you can see how it works in jsfiddle. Please let me know if I missed anything.
html
<div id="slideshow">
<ul>
<li class="slideshow_item">
<a href="#"><img src="http://www.google.com/logos/2011/persiannewyear11-hp.jpg" alt="persiannewyear11-hp" /></a>
</li>
<li class="slideshow_item">
<a href="#"><img src="http://www.google.com/logos/2011/holi11-hp.jpg" alt="holi11-hp" /></a>
</li>
<li class="slideshow_item">
<a href="#"><img src="http://www.google.com/logos/2011/sayeddarwish11-hp.jpg" alt="sayeddarwish11-hp" /></a>
</li>
<li class="slideshow_item">
<a href="#"><img src="http://www.google.com/logos/2011/okamoto11-hp.jpg" alt="okamoto11-hp" /></a>
</li>
<li class="slideshow_item">
<a href="#"><img src="http://www.google.com/logos/2011/eisner11-hp.jpg" alt="eisner11-hp" /></a>
</li>
<li class="slideshow_item">
<a href="#"><img src="http://www.google.com/logos/2011/jfkinaugural11-hp.jpg" alt="jfkinaugural11-hp" /></a>
</li>
</ul>
</div>
Jquery
/* home slide show */
var slide_pos = 0;
var slide_len = 0;
$(document).ready(function() {
slide_len = $(".slideshow_item").size() - 1;
$(".slideshow_item:gt(0)").hide();
slide_int = setInterval(function() {
slide_cur = $(".slideshow_item:eq(" + slide_pos + ")");
slide_cur.fadeOut(2000);
slide_pos = (slide_pos == slide_len ? 0 : (slide_pos + 1));
slide_cur = $(".slideshow_item:eq(" + slide_pos + ")");
slide_cur.fadeIn(2000);
}, 5000);
});
css
#slideshow{
position:relative;
top:0;
left:0;
} #slideshow ul, #slideshow li{
margin:0;
padding:0;
list-style-type:none;
} .slideshow_item{
position:absolute;
left:0;
top:0;
list-style-type:none;
} .slideshow_item img{
margin:0;
padding:0;
vertical-align:bottom;
}
Upvotes: 2