Normally, User starts to fill a form,always to select the first input field on the page.Here,the following little trick will work for any situation automatically on page load. I will explain you, how to focus the first input field in jQuery.
HTML CODE: Copy and paste the following html Code.
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$("input[type=text]:first").focus();
});
</script>
<div class="bs-example">
<form>
<h1>JQuery focus </h1>
<div class="form-group">
<label for="inputEmail">First Name</label>
<input type="text" class="form-control" id="inputFirstName" placeholder="First Name">
</div>
<div class="form-group">
<label for="inputPassword">Last Name</label>
<input type="text" class="form-control" id="inputLastName" placeholder="Last Name">
</div>
</form>
</div>
Note: User do not forget to register the jQuery plugin on the head section of the page.
Post your comments / questions
Recent Article
- ModuleNotFounEerror:No module named celery in Django Project
- How to get domain name information from a Domain using Python
- ModulenotFoundError: no module named 'debug_toolbar' -SOLUTION
- How to create superuser in django project hosted in cPanel without terminal
- CSS & images not loading in django admin | cpanel without terminal
- Could not build wheels for mysqlclient, which is required to install pyproject.toml-based projects
- How to sell domain name on Godaddy (2023)
- TemplateSyntaxError at / Could not parse the remainder: ' + 1' from 'forloop.counter0 + 1'
Related Article