Auto Focus in Search Form

This code snippet is to create an auto focus function in the search form when the search button is clicked.
Share:
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...
Updated: 9 June 2021
favico digitalizer

This code snippet is to create an auto focus function in the search form when the search button is clicked. In the code sample below, the search button has the id #iconsearch.

I took this code snippet from https://perishablepress.com/code-snippets/ and I also use it on the Digitalizer My ID website, but there is a slight modification of the chant so that I can put it in the javascript tab of the Code Block Oxygen Builder component.

jQuery(document).ready(function(){
  jQuery("#iconsearch").bind('click',function(){
    setTimeout(function(){jQuery('#s').focus();},25);
    return true;
  });
});

Leave a Reply

Your email address will not be published. Required fields are marked *

Latest Article

Animation Counter Javascript
Javascript code to display running count numbers
Read more...
HTML Code to Redirect Domain
HTML code to automatically redirect visitors who open a particular domain address to another domain address.
Read more...
Add Code Snippet to a Specific Page Header
Code Snippet to add specific code to a specific page header.
Read more...
COMPLETE PACKAGE OF WEBSITE DESIGN & DEVELOPMENT
Digitalizer offers website design & development services for company profiles, online shops, event organizers, educational institutions or other fields. You don't need to think about domains, web hosting / servers, DNS, email, design, development, security and other technical issues. Just prepare your website content, we do the rest.
All website design & development packages include 1 year maintenance!
Free Consultation
Back to top
logo digitalizer - en
© 2011 - 2021 Digitalizer My ID