Array of images or emoji

Hello everyone! I am new here . Can anyone tell me how can I make an array of emoji or images and then display them in a div on the webpage? **
8 Replies
mahmoud_e
mahmoud_e16mo ago
show us what you have done so far. post your html and js codes and we can guide you properly. if you want someone to write the entire code for you, then chat gpt can you the answer much faster.
Rook
Rook16mo ago
const emojis = ['🫶', '❤️', '🔥']
emojis.forEach(emoji => {
const div = document.createElement('div')
div.append(emoji)
document.body.append(div)
})
const emojis = ['🫶', '❤️', '🔥']
emojis.forEach(emoji => {
const div = document.createElement('div')
div.append(emoji)
document.body.append(div)
})
lol ¯\_(ツ)_/¯ but yeah it's kinda hard to help you without seeing anything that you've tried to do to solve it
croganm
croganm16mo ago
Try setting the div.textContent = emoji Just a thought since an emoji is just a string. You definitely can't append something to an element though
Rook
Rook16mo ago
wdym? that is probably a clearer approach, but append (and this solution) works just fine, since append can also accept a string as an argument. you end up with
<div>🫶</div>
<div>❤️</div>
<div>🔥</div>
<div>🫶</div>
<div>❤️</div>
<div>🔥</div>
croganm
croganm16mo ago
Really? It's able to take text as an element in js? Sorry, that was just a little surprising. I apologize, on mobile or else I would have tested it myself
Rook
Rook16mo ago
Yeah! I think appendChild only takes nodes, but append takes both :) i need to brush up on my vanilla js stuff ;-;
croganm
croganm16mo ago
Good to know! 🙂
verakissyou17
verakissyou17OP16mo ago
+Thanks everyone for your help!
Want results from more Discord servers?
Add your server