The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

Reply to this topicStart new topic
> Script for rotating words
post 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";

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
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:


- Lo-Fi Version Time is now: 5th March 2021 - 01:53 PM