lundi 26 novembre 2018

How to randomly order two synchronized lists?

Aparently suffling an array is not so complicated: How to randomize (shuffle) a JavaScript array?

But what if I have to (Html DOM) lists that are synchronized and I need to suffle the order of the elements, but they should have the same final order?

Example, Initial state:

A)

<ul> <li>First title</li> <li>Second Title</li> <li>Thrid title</li> </ul>

B)

<ul> <li>First text</li> <li>Second text</li> <li>Thhird text</li> </ul>

After suffle

A)

<ul> <li>Second title</li> <li>First Title</li> <li>Thrid text</li> </ul>

B)

<ul> <li>Second text</li> <li>First text</li> <li>Third text</li> </ul>

How can this be achieved?




Aucun commentaire:

Enregistrer un commentaire