+ 1

Hey guys my function is not working

Trying out set attribute https://code.sololearn.com/WwkPloSh81Ih/?ref=app

13th Feb 2022, 10:40 PM
D Doyen
D Doyen - avatar
9 Respuestas
+ 1
Ipang Pls don't be annoyed for disturbing you Pls my set attribute is not working
13th Feb 2022, 10:40 PM
D Doyen
D Doyen - avatar
0
My get attribute is not working Ipang How it not working it says undefined
13th Feb 2022, 11:30 PM
D Doyen
D Doyen - avatar
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;
14th Feb 2022, 12:31 AM
Ipang
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]() }
14th Feb 2022, 7:47 AM
D Doyen
D Doyen - avatar
0
It works the way I wrote it but var index is throwing a error of undefined when I click on the red button
14th Feb 2022, 7:48 AM
D Doyen
D Doyen - avatar
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
14th Feb 2022, 7:57 AM
D Doyen
D Doyen - avatar
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
14th Feb 2022, 7:58 AM
D Doyen
D Doyen - avatar