By this you can randomize your image orders, javascript need to be involved in this task.
(这样,您可以随机分配图像顺序,此任务需要使用JavaScript。)
First I get the main element of the HTML, get all the children in array to random it, at the end give you the result:
(首先,我得到了HTML的主要元素,将数组中的所有子元素都随机化了,最后得到了结果:)
var numbers = document.querySelector('#numbers'); var list = Array.from(numbers.children); var newlist; list.sort(function(a, b) { return -1 + Math.random() * 3; // -1, 0, or 1 }); while (numbers.children.length > 0) { numbers.removeChild(numbers.children[0]); } list.forEach(function(el) { numbers.appendChild(el); });
<ul id="numbers"> <li><a href="#"><img src="images/medium/1.jpg"/>1</a></li> <li><a href="#"><img src="images/medium/2.jpg"/>2</a></li> <li><a href="#"><img src="images/medium/3.jpg"/>3</a></li> <li><a href="#"><img src="images/medium/4.jpg"/>4</a></li> </ul>
Note: something it gives you the same result, but most of the time randomize it, as we know we're not using AI to not give us the old result.
(注意:有些东西可以为您提供相同的结果,但是大多数时候都会将它随机化,因为我们知道我们不是在使用AI来提供旧的结果。)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…