+ 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.
12 Answers
+ 6
/*try and work with this*/
window.onclick =function change(){
var y= document.getElementsByClassName("first");
y[0].style.background ="blue"; }
+ 8
First fix the addEventListener issue by following this:
https://www.sololearn.com/post/7444/?ref=app
+ 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.
+ 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());};
+ 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 đđ
+ 3
you could set attributes in javascript?
+ 3
AZTECCO k thx đ
+ 2
help me plz
+ 2
D_Stark np thx for helpđ
+ 1
yes
+ 1
AZTECCO can u do it inside my code? when I click on face the color of the face will change to yellow
+ 1
D_Stark thx for help
How can I do this? it changes color only when I click on it