Ok, in .js
file
....
document.getElementById("lessonSelect").addEventListener("load", getAllLessonNos());
....
In html file
,
<button onclick="getAllLessonNos()">Show All Lessons</button>
<select id="lessonSelect"> </select>
Nothing happened after the page is loaded, that is the function getAllLessonNos()
has not been called.
However, when I click the button "Show All Lessons", it will show all lessons without any problems.
This webpage say we can do "object.addEventListener("load", myScript);
"
So, what is wrong?