How to randomly select one of the list by clicking the button

clipboard.png

< H2 > as shown in the figure, how to click the button to randomly select one of the rows < / H2 >
Mar.23,2021

Math.floor ((Math.random () * arr.length)) do the specific DOM operations yourself


you need to use the random method of the built-in object Math in js

var num = Math.floor(Math.random() * 10)

Math.random () * 10, and using floor () to round down, you can randomly get the 10 numbers of 0,9, that is, the subscript of these p elements in your diagram. Then you can get the corresponding p element according to the subscript and then manipulate the DOM.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e64dd9-5a06b.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e64dd9-5a06b.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?