Set focus on Search bar

When clicking on the search icon, it opens the search bar. To put focus in it directly, without having to click twice, do the following:
Go to file js/main.js and find this function:

function codelessSearchButton(){
"use strict";
$('.open_search_button').click(function(){
if($('body').hasClass('open_search')){
$('body').removeClass('open_search');
}else
$('body').addClass('open_search');
});

edit it to this:

function codelessSearchButton(){
"use strict";
$('.open_search_button').click(function(){
if($('body').hasClass('open_search')){
$('body').removeClass('open_search');
}else
{ $('body').addClass('open_search');
$('.search_bar input[type="text"]').focus();}
});

It has only this additional line: $('.search_bar input[type="text"]').focus();
Save file and refresh.

Comments

comments

Was this article helpful?

Related Articles

Leave A Comment?