Javascript examples for DOM HTML Element:Input FileUpload
The autofocus property sets or gets whether a file upload button should get focus when the page loads.
This property reflects the HTML autofocus attribute.
Set the autofocus property with the following Values
Value | Description |
---|---|
true|false | Sets whether a file upload button should get focus when the page loads |
A Boolean, returns true if the file upload button gets focus when the page loads, otherwise it returns false
The following code shows how to check if a file upload button automatically gets focus upon page load:
<!DOCTYPE html> <html> <body> <input type="file" id="myFile" autofocus> <p id="demo"></p> <button onclick="myFunction()">Test</button> <script> function myFunction() {//from w ww . j a va 2 s.c o m var x = document.getElementById("myFile").autofocus; document.getElementById("demo").innerHTML = x; } </script> </body> </html>