samedi 15 juillet 2017

How to assign a random id to a HTML element?

I am working on a project and it is a guessing game. I want the order of the buttons to be random so that the correct answer wont always be the left one, for example. So my HTML buttons ids are "1", "2", "3", "4" and i want to assign each of them a random id (ex. 1 becomes 4) bI have already tried to do math.random and make it 1-4 there is a chance of overlapping numbers. How can i make it so the numbers don't overlap? Thanks!




Aucun commentaire:

Enregistrer un commentaire