scriptnewbie
New Coder
I want to replace all .emoji elements, with a random weather emoji. I have written the following code to randomize an emoji:
And the following to insert a random emoji into my page:
This works, but only with the first .emoji element.
When cahnging it to ,
nothing works.
How do I replace all .emoji elements?
Any help is appreciated!
JavaScript:
let weatherEmojis = [
"⚡️","☀️","⛅️","☁️","💧","💦","☔️","💨","❄️"
];
var weatherEmoji =
weatherEmojis[Math.floor(Math.random() * weatherEmojis.length)];
And the following to insert a random emoji into my page:
let currentEmoji = document.querySelector(".emoji");
currentEmoji.innerHTML = weatherEmoji;
This works, but only with the first .emoji element.
When cahnging it to ,
let currentEmoji = document.querySelectorAll(".emoji");
currentEmoji.innerHTML = weatherEmoji;
nothing works.
How do I replace all .emoji elements?
Any help is appreciated!