D
D
dolphineo2017-04-22 07:27:55
JavaScript
dolphineo, 2017-04-22 07:27:55

Assign random class to list on click?

Each new page (list) load assigns a random class to an N-list element...
4353444.jpg

var random = Math.floor(Math.random() * 1000);
var $li = $("#gallery li");
$li.eq(random % $li.length).addClass("on");

But how is it the same, only a random class is assigned by clicking on “I'm lucky!”, each time changing the value to a new one, and “Reset” will delete this class?
Edit jsfiddle

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question