Set focus on elements with .focus()

.focus()


Description: Set focus to a element.


Example:

<!doctype html>
    <html lang="en">
    <head>
      <meta charset="utf-8">
      <title>focus demo</title>
      <script src="http://code.bitsycode.com/bitsycode-latest.min.js"></script>
    </head>
    <body>
      
      <input type="text" name="textField" class="textField" value="Focus on this field" /><br /><br />
      <button onclick="focusIt()">Set Focus</button>
      
      <script type="text/javascript">
         
         function focusIt() {
             bitsyCode(".textField").focus();
         }
         
      </script>
     
    </body>
    </html>

Preview:



  • Usage

    • How to use:

      Set focus to an element

    • USAGE:

      bitsyCode("element").focus();
  • Options

    • What options are there:

      There are no options for this method.

  • Returns

    • Returns: No return type

      This method does not need to return any type.

Share