El.style doesn't work | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

El.style doesn't work

Hi, Why won't this code move my element? window.onload = () =>{ function addTextEl(x){ let a = document.createElement('span'); a.innerHTML = '🔥' document.body.appendChild(a) a.style.left = x } addTextEl(0) addTextEl(50) } I'm using basic HTML, CSS design, no changes at all. This code produces the text in same location ALWAYS, (2 '🔥' always one by the other, even when I change x) why??

28th Mar 2022, 8:17 PM
Lior Bakal
Lior Bakal - avatar
2 Answers
+ 1
FF9900 I see that you added 'px' Thanks!
28th Mar 2022, 8:35 PM
Lior Bakal
Lior Bakal - avatar
0
FF9900 I deleted the CSS and its working. What are the display: block, and body 'overflow: hidden'?
28th Mar 2022, 8:39 PM
Lior Bakal
Lior Bakal - avatar