1

I have got "slides" div and "slidecontrols" div. slidecontrols div contains thumbnail and title of slides and it's displaying title and raising opacity when activate one slide.

slides and slidecontrols are in array on javascript and appending to page with jquery.

I need to randomize sorting of slides every page refresh but when randomizing slides and slidecontrols there is problem appears..

think like :

slides : 1, 2, 3, 4, 5

slidecontrols : 1a, 2a, 3a, 4a, 5a

after randomizing :

slides : 3, 2, 1, 5, 4

slidecontrols : 4a, 2a, 5a, 1a, 3a

but I want this sorting after randomizing :

slides : 3, 2, 1, 5, 4

slidecontrols : 3a, 2a, 1a, 5a, 4a

2 Answers 2

2

You don´t have to randomize both. You have to randomize the slides and then sync the slidecontrols with them instead ;)

Sign up to request clarification or add additional context in comments.

Comments

1

Try this, though there are some temp variabls

var a = [1, 2, 3, 4, 5];
var b = ['1a', '2a', '3a', '4a', '5a'];
var temp = [];
var i = 0;
a.sort(function() { return temp[temp.length] = (Math.random() - 0.5); });
b.sort(function() { return temp[i++]; });

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.