Focus input

Description

The following code shows how to focus input.

Example


<html>
<head>
<script
  src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script type="text/javascript">
  $(document).ready(<!--from   ww w .j  a  va 2s .c om-->
      function() {
        $("button").click(
            function() {
              $(this).next().removeAttr("disabled").focus().val(
                  "java2s.com now");
            });
      });
</script>
</head>
<body>
  <button>Enable</button>
  <input type="text" disabled="disabled" value="can't edit this" />
</body>
</html>

Click to view the demo





















Home »
  jQuery »
    jQuery Example »




Animation
DOM
Event
Form
List
Select
Style
Table
Utilities