+ 1
Hey guys my function is not working
Trying out set attribute https://code.sololearn.com/WwkPloSh81Ih/?ref=app
9 Respuestas
+ 1
Ipang
Pls don't be annoyed for disturbing you
Pls my set attribute is not working
0
My get attribute is not working
Ipang
How it not working it says undefined
0
D Doyen,
What should I do to test it? how it should be working?
Line 51:
buttons[ i ].onclick=function(){
submit();
}
Try to directly assign submit() instead
buttons[ i ].onclick = submit;
0
Ipang
This var index is throwing an error of undefined
It would call the function txt[index]() store in an array
Function submit(){
var index = this.getAttribute("index"); // button index
txt[index]()
}
0
It works the way I wrote it but var index is throwing a error of undefined when I click on the red button
0
I think I solved it now
It throws a error of undefined if I use onclick but throws no error if I use addeventlistener
0
Why
What is the difference BTW onclick and addeventlistener that makes it throw an error of undefined with onclick and does not if I use addeventlistener