16th Jul 2020, 4:33 AM
Kashyap Kumar
Kashyap Kumar - avatar
3 Answers
+ 6
I do not know why you would write: if(el1) https://code.sololearn.com/W9C95bwVKaxr/?ref=app but here is the fixed code. I removed the if statement from the event Listeners section and made them get added only after Dom is loaded. ;)
16th Jul 2020, 4:55 AM
Saphal Poudyal
Saphal Poudyal - avatar
+ 6
window.onload = function() { // add event listener for the 3 elements here } At the moment the code refers to elements before the DOM is fully setup, the elements you refer to, are not yet prepared to be used.
16th Jul 2020, 4:59 AM
Ipang
+ 4
Thanks Ćheyat and Ipang
16th Jul 2020, 5:20 AM
Kashyap Kumar
Kashyap Kumar - avatar