• Hello!

    I have little to no development experience however I’m looking to default the cursor on the Search bar on a popup I have.

    Go to [ redundant link removed ]k on a mobile device, select the Search Icon and this opens up the popup

    Is there a way for the cursor to default in the search bar for me?

    Thanks

    • This topic was modified 4 years, 4 months ago by Jan Dembowski. Reason: Moved to Fixing WordPress, this is not an Developing with WordPress topic

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • 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?

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Default cursor on page open’ is closed to new replies.