Script for rotating words |
Script for rotating words |
nightoul |
Mar 27 2020, 04:13 AM
Post
#1
|
Group: Members Posts: 3 Joined: 19-March 20 Member No.: 27,239 |
I do hope this is the right thread. I have a script that I have found which upon refreshing the browser changes images at random. I need this functionality for my online teaching these days since our school got cancelled now and we carry on teaching via Google Hangouts. This is what the script looks like:
<script type="text/javascript"> function range1(i) { return i ? range1(i - 1).concat(i) : []; } var images = range1(25); var item = images[Math.floor(Math.random() * images.length)]; document.getElementById("image").src = "./" + item + ".jpg"; </script> It works nice for me but I would like to make it work for text also. Can somebody help make the changes please? I only know a bit of HTML and this is meaningless for me (I only figured out that you can change the "var images = range1(25)" to accomodate for the number of images in the folder). I want to be able to insert 25 words (perhaps in 25 separate <p> tags?) and change them upon refreshing the page. Thank you! This post has been edited by nightoul: Mar 27 2020, 04:13 AM |
Lo-Fi Version | Time is now: 23rd April 2024 - 01:59 AM |