I want to use a random number like this website "https://yogylove.myshopify.com/" for wordpress website. Number will be change in 5 or 10 seconds automatically
Asked
Active
Viewed 411 times
-4
-
1And the question/problem is? If you're "asking" for a working solution then SO is not the right place. – Andreas Sep 18 '19 at 12:10
-
Please show us what you have tried yourself to create this. – Carsten Løvbo Andersen Sep 18 '19 at 12:10
-
[Generate a number](https://stackoverflow.com/q/1527803), [put it in the div](https://stackoverflow.com/q/2554149) and [repeat it every x seconds](https://stackoverflow.com/q/3138756). – Ivar Sep 18 '19 at 12:13
-
@CarstenLøvboAndersen i have tried some codes from google. But not worked. – Karan Kcoresys Sep 18 '19 at 12:19
-
Possible duplicate of [Div with random values that change with time](https://stackoverflow.com/questions/42092105/div-with-random-values-that-change-with-time/42092326) – Ivar Sep 18 '19 at 12:20
-
thank you @Ivar, those numbers showing like "0.1323955413795357". can it be just one number like "1" "2" – Karan Kcoresys Sep 18 '19 at 12:23
-
@KaranKcoresys See the first link in my first comment on how you can generate a number in a range. – Ivar Sep 18 '19 at 12:24
1 Answers
-1
Try this snipper:
let genRnd = function() {
var min=0;
var max=9;
return Math.floor(Math.random() * (+max - +min)) + +min;
};
setInterval(
function() {
document.getElementById("cont").innerHTML = genRnd();
},
500
);
<div id="cont"></div>

Pablo Santa Cruz
- 176,835
- 32
- 241
- 292