0

How can we put HTML lists inside a JavaScript array?

I would like to create a button like either of these: 1) https://www.randomanime.org --> the orange "Generate Random List" button 2) https://random-ize.com/random-youtube/ --> the grey "Generate Another!" button As of now, I've done the following: ========================================================================= <!DOCTYPE HTML> <html> <head> </head> <body style = "text-align:center;"> <br> <button id = "button" onclick = "random_element()">click here</button> <h1 style = "color:pink;"> Project Title</h1> <hr> <hr> <hr> <p id = "ZZZ" style = "font-size: 14px; color: #a8bcff;"></p> <script> var zzz = document.getElementById('ZZZ'); var arr = ["aaa", "bbb", "ccc", "ddd"]; <!--how do we put HTML lists in this array? --> function random_element() { zzz.innerHTML = arr[Math.floor(Math.random() * arr.length)]; } </script> <hr> <hr> <hr> </body> </html> ========================================================================= I understand how to generate random elements in the form of text. But I don't know how to make a JS array that contains all of the html lists of videos. What's the proper way to reference and USE html <li></li>/<iframes></iframes> inside a JavaScript array?

20th Sep 2020, 1:39 PM
Solus
Solus - avatar
1 Answer
0
Seek help from Google or w3schools.com
22nd Sep 2020, 5:03 PM
Masih Khan