+ 1

I need a help with animation

https://code.sololearn.com/W88tN0bjQG3y/?ref=app I want to change background of my faces by clicking on them.

25th Sep 2018, 11:52 AM
patos
patos - avatar
12 Answers
+ 6
/*try and work with this*/ window.onclick =function change(){ var y= document.getElementsByClassName("first"); y[0].style.background ="blue"; }
25th Sep 2018, 1:08 PM
D_Stark
D_Stark - avatar
+ 8
First fix the addEventListener issue by following this: https://www.sololearn.com/post/7444/?ref=app
25th Sep 2018, 12:30 PM
Burey
Burey - avatar
+ 6
patos i think you have to rewiew your css.. first thing I notice is the first id and class , this suggests your design it's not clear and so you may not have a clear idea of what you want to achieve. One of the most important rules in naming conventions tells: if you find hard to give a proper name to an obj,function class or whatever, there's probably a problem in your design and script.
25th Sep 2018, 2:38 PM
AZTECCO
AZTECCO - avatar
+ 5
the element is not born yet, window.onload() fires after the DOM is fully constructed window.onload= function (){ document.getElementById("first").addEventListener("click", change());};
25th Sep 2018, 12:30 PM
AZTECCO
AZTECCO - avatar
+ 4
patos your welcome, sorry its not perfect, im new to this too, if not resolved i will have a better look later and get it working 😉👍
25th Sep 2018, 1:19 PM
D_Stark
D_Stark - avatar
+ 3
you could set attributes in javascript?
25th Sep 2018, 12:02 PM
D_Stark
D_Stark - avatar
+ 3
AZTECCO k thx 😉
25th Sep 2018, 4:44 PM
patos
patos - avatar
+ 2
help me plz
25th Sep 2018, 12:11 PM
patos
patos - avatar
+ 2
D_Stark np thx for help😊
25th Sep 2018, 1:20 PM
patos
patos - avatar
+ 1
yes
25th Sep 2018, 12:11 PM
patos
patos - avatar
+ 1
AZTECCO can u do it inside my code? when I click on face the color of the face will change to yellow
25th Sep 2018, 12:42 PM
patos
patos - avatar
+ 1
D_Stark thx for help How can I do this? it changes color only when I click on it
25th Sep 2018, 1:09 PM
patos
patos - avatar