0

Why does this JavaScript doesnt script the html div. Function after the "click" is defined too

document.getElementById("display").addEventListener("click", display); document.getElementById("searchnumber").addEventListener("click",searchnumber); document.getElementById("searchname").addEventListener("click",searchname); document.getElementById("quit").addEventListener("click",quit);

7th Nov 2016, 10:54 PM
Michael W.
Michael W. - avatar
2 ответов
+ 3
Maybe because of script is starts before all elements are loaded? Put your code in <script></script> at the bottom of body. Or put code in window.onload = function(){/*put here*/} and check how it works.
7th Nov 2016, 11:25 PM
Aleksandr Efimov
Aleksandr Efimov - avatar
+ 1
ok Works fine if i put the Script into the End of Body of html. is There a Way to seperate it into the js Part of coding? thank u for ur answer. ok Moment i will try the "onload"
7th Nov 2016, 11:25 PM
Michael W.
Michael W. - avatar