Skip to content

adamyanalunas/Polite-Focus

master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
js
 
 
 
 
 
 

Polite Focus

Don't be rude to your users. Let them decide what to focus on.

This is a nice way of asking the browser to give you focus of a form field. Better yet, it's simple. If no other field has focus, you can have it. If some other field has focus, leave it there.

Example!

<form action="" method="post">
    <fieldset id="your_login_form" class="">
        <legend>Your login form</legend>
        
        <label for="username">Username</label><input type="text" name="username" value="" id="username">
        <br>
        <label for="password">Password</label><input type="password" name="password" value="" id="password">
    </fieldset>
    
    <p>
        <button type="submit">Login</button>
    </p>
</form>

<script>
/* <![CDATA[ */
    $('#username').politeFocus();
/* ]]> */
</script>

About

A nicer way of asking for focus on a form element

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published