+ 1
Why did my div contents refused to swap?
I just started a JavaScript course and don't understand why my divs did not swap contents when I click on the buttons. https://code.sololearn.com/WFlNkj5Q26Vg/?ref=app
5 odpowiedzi
+ 2
Here you go:
https://code.sololearn.com/W8MpUd63qlro/?ref=app
You need to use AddEventListener, so html could see your swap function. (Also you defined swap function wrong)
And finally you used InnerHTML rather than innerHTML....
But the code I've sent you works)))
+ 2
Answer of Aleksei Radchenkov is also one way of handle this problem, but i was removed window.onload, because you call function on btn click, so nothing need to load before in js. Also i set in html onclick="swap('facebook','apple')"
you misplased ", it was onclick=swap"(...)", and it is lower Camal Case for innerHTML
https://code.sololearn.com/W2DwPalc3max/?ref=app
+ 1
For color swap you need inside js to add style
0
Aleksei Radchenkov pls I need your help here as well. Or probably you may know someone who can help. Tag him or her. 🙏🙏
0
Sanja Panic thank you. But I thought the div color would swap as well as their content