External JS with onLoad Event
问题 I have an external js file which has a function that is meant to run AFTER the document body has loaded. This is what I have so far but it's not working as it should. Some help please. External JS File window.document.body.addEventListener('load', numOfSelects()); function numOfSelects() { var selects = document.getElementsByTagName('select'); alert(selects.length); } The HTML file that calls this script does have a few select fields. The alert works but it shows 0. And after the alert shows