Keeping the focus on the JQuery Search Box

Is there any way to assign the Search box on a JQuery/JSON/DataTable page the focus?  I want the page below to have the search box keep the focus so end users viewing their results can just step up and enter their bib number to view their results.  Thanks!
Bob SchneiderCo-OwnerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Use : jQuery("#results_filter input").focus();
Bob SchneiderCo-OwnerAuthor Commented:
Does that go in a script tag?
of course and you should put this code just after your datatable is created

jQuery(window).on("load", function() { // wait for all elements loaded in the page
    setTimeout(function() {
         jQuery("#results_filter input").focus();
     , 1000); // wait 1 second before setting focus on the textbox

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Julian HansenCommented:
I would build on the DT draw event
You don't have an id on the search so using this approach

var inp = $('#results_filter input');
$('#results').on( 'draw.dt', function () {
} );

Open in new window

Bob SchneiderCo-OwnerAuthor Commented:
Thank you both so much!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.