Element focus() Method - Give focus to a text field, immediately after the document window has been loaded: - Javascript DOM

Javascript examples for DOM:Element focus

Description

Element focus() Method - Give focus to a text field, immediately after the document window has been loaded:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<input type="text" id="myText" value="A text field">

<script>
window.onload = function() {/*from   ww w  . j a  va2s  .c om*/
  document.getElementById("myText").focus();
};
</script>

</body>
</html>

Related Tutorials