I am building a search engine. How can I have the input tag (type="text") be focused when the page loads so people can start searching straight away without having to click on it?
            Asked
            
        
        
            Active
            
        
            Viewed 192 times
        
    -2
            
            
         
    
    
        Just a student
        
- 10,560
- 2
- 41
- 69
 
    
    
        Alex Bailey
        
- 31
- 2
- 
                    Welcome to Stack Overflow, we expect at least some research before asking a question. There is at least one question on this site that answers exactly this and numerous results on any given search engine. – Jon P Nov 06 '16 at 23:57
2 Answers
2
            
            
        You're looking for the autofocus attribute, which does exactly that.
 
    
    
        SLaks
        
- 868,454
- 176
- 1,908
- 1,964
0
            
            
        Use jQuery and .focus() method.
$( document ).ready(function() {
    $('#search_input').focus();
});<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="text" id="search_input"> 
    
    
        El Danielo
        
- 780
- 1
- 8
- 18