Button.focus() : Button : Form JAVASCRIPT TUTORIALS


JAVASCRIPT TUTORIALS » Form » Button »

 

Button.focus()









Syntax








document.form.button.focus()



The focus() method applies focus to the button without invoking the button's onFocus event handler.












<html>

    <script language="JavaScript">
    <!--
    function moveFocus()
    {
      document.myForm.button1.focus();
    }
    -->
    </script>
    <form name="myForm">
      <input type="button"
             value="I hold my focus after a click"
             name="button1"><br>
      <input type="button"
             value="I shift my focus when click"
             name="button2"
             onClick="moveFocus()">
    </form>    
    </html>







HTML code for linking to this page:

Follow Navioo On Twitter

JAVASCRIPT TUTORIALS

 Navioo Form
» Button