I want to get all input element in html page. I\'ve tried this:
window.onload = function(){
input = document.querySelectorAll(\"input\");
}
Reference your script tags at the bottom of the HTML page and not in the head. This will remove any ambiguity as to whether the page has been loaded.
window.onload = function(){
input = document.querySelectorAll("input");
alert(input.length);
}
Now you should be able to extract the code from "window.load()" and get the expected results.
input = document.querySelectorAll("input");
alert(input.length);