-
December 7th, 2010, 06:49 PM
#1
Simple JQuery Slideshow that Refreshes Order of Pictures
Right now on my current website, I have it going through the pictures in the order of the array, but I would like it so whenever the user refreshes the website, the slideshow randomly shuffles the pictures in a different order.
Code:
<script type="text/javascript">
var imgs = [
'images/slideshow/001.jpg',
'images/slideshow/002.jpg',
'images/slideshow/003.jpg',
'images/slideshow/004.jpg',
'images/slideshow/005.jpg',
'images/slideshow/006.jpg'];
var cnt = imgs.length;
$(function() {
setInterval(Slider, 3000);
});
function Slider() {
$('#imageSlide').fadeOut("slow", function() {
// the source of the problem
$(this).attr('src', imgs[Math.floor (Math.random( ) * imgs.length) % cnt]).fadeIn("slow");
});
}
</script>
Any help is appreciated! =]
-
December 7th, 2010, 07:09 PM
#2
Re: Simple JQuery Slideshow that Refreshes Order of Pictures
There are plenty examples out there on how to sort an array randomly. Search Google for "JavaScript array random sort."
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
-
December 7th, 2010, 07:23 PM
#3
Re: Simple JQuery Slideshow that Refreshes Order of Pictures
Thank you for that tip!
I wanted to know if I could interchange JavaScript techniques with JQuery because I wanted to try and use these tips:
http://hungred.com/how-to/tutorial-s...ay-javascript/
-
December 7th, 2010, 09:23 PM
#4
Re: Simple JQuery Slideshow that Refreshes Order of Pictures
It's 3 lines of code. Why waste the resources to interact with jQuery? Since jQuery doesn't have a random sorting method included, you'd have to extend the jQuery framework which would be more work.
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
-
June 14th, 2013, 09:29 PM
#5
Re: Simple JQuery Slideshow that Refreshes Order of Pictures
Just to add to this here is a really basic slider I enjoy using. I like it cause the code is really easy to understand and it includes thumnails, next and previous buttons and a rotating description section too
http://codetutorial.caroshaw.com/jqu...age_slider.php
-
June 24th, 2013, 08:45 AM
#6
Re: Simple JQuery Slideshow that Refreshes Order of Pictures
Welcome to the forums alicialou!
Please remember to keep your posts relevant. This thread is 3 years old!
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|