Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

126
Views
Toggle Search Input Autofocus

I am running a script when the search icon is clicked the search input is displayed with toggle but I cannot get this running so that the input autofocus is active so the user can type straight into the search box

    $(document).ready( function(){ 
         $("#velaSearchTop").each( function(){
            $("#velaSearchIcon").click( function(){
                 $("#velaSearchbox").toggleClass("show");
             });
            $(".btn-close").click( function(){
                 $("#velaSearchbox").removeClass("show");
             });
         }); 
    });
</script>


<div id="velaSearchTop">
    <span id="velaSearchIcon" class="fa fa-search"></span>
    <form id="velaSearchbox" class="formSearch" action="/search" method="get">
        <input type="hidden" name="type" value="product">
        <input class="velaSearch form-control" class="test" type="search" name="q" value="{{ search.terms | escape }}" placeholder="{{ 'general.search.placeholder' | t }}" autofocus />
        <button id="velaSearchButton" class="btnVelaSearch" type="submit" >
            <span><i class="fa fa-search"></i></span>
            <span class="btnSearchText">{{ 'general.search.submit' | t }}</span>
        </button>
        <div class="btn-close"><span class="fa fa-close"></span></div>
    </form>
</div>```
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

If you're using jquery.js you can write like this

$(function () {
    $("#velaSearchIcon").click(function () {
        $("#velaSearchbox").show();
        $("input[name='q']").focus();
    });
    $(".btn-close").click(function () {
        $("#velaSearchbox").hide();
    });
});
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!