You can use javascript to bring focus() to the search bar on page load.
Like this:
http://jsfiddle.net/stevegreatrex/gnRu6/
You could try adding this in the header.php file of your child theme:
<script>
$(function() {
$("input[id='product-search-field-0']").focus();
});
</script>
Thread Starter
Phenix
(@proshop)
Thanks for responding, however it doesn’t appear to work
I also tried using the id product-search-field-2 as this is what it appears to show as when I inspect on my browser but still no luck…
Any additional help would be much appreciated!!
Right, we were looking at different boxes – see here:
https://postimg.cc/DJ6Dqmgs
Are you sure you wrapped your open and close script tags properly?
You could also try this like this instead:
https://pastebin.com/RYTbKEZd
Thread Starter
Phenix
(@proshop)
Ah thank you yes we were looking at different search boxes. For the desktop site it works now however the search box I was hoping to get this to work for is on the mobile site.
There’s a search icon in the header on the mobile site, selecting this opens a popup where the search bar is, it’s this search bar I was hoping to default the cursor to if possible
Really appreciate the help!
Thread Starter
Phenix
(@proshop)
also, I’ve changed the id to match this search box but it doesn’t appear to work. From my limited knowledge I’d assume this is because its added to the header.php file and this popup is not part of the header?