Elliot S Elliot S - 1 month ago 5
HTML Question

Set autofocus to an input in html?

I have some html code and I've heard that autofocus will speed up search results etc. How can I do that with existing code?

I have been looking on other threads etc how to do this and I have tried to understand but I can't if someone could help me out here I would be awesome.



<input type="text" class="form-control" id="query" name="query" value="<?php if($this->input->post('query')) { echo $this->input->post('query'); } ?>" placeholder="Search here">




Answer

Add the autofocus to your input attribute.

<input type="text" class="form-control" id="query" name="query" value="<?php if($this->input->post('query')) { echo $this->input->post('query'); } ?>" placeholder="Search here" autofocus>

Comments