• Resolved sparre

    (@sparretun)


    Hi,

    When a visitor clicks on “S?k” (Search), we want the search field to be marked so that you can directly start typing in what you want to search for. Is it possible to solve?
    WP Ocean with Elementor.

    Best regards,

    Fredrik

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

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author ILLID

    (@mihail-barinov)

    Hello,

    Looks like I found the solution for you. Please use following code snippet

    add_action( 'wp_footer', 'aws_wp_footer' );
    function aws_wp_footer() { ?>
    
        <script>
            window.addEventListener('load', function() {
                if ( typeof jQuery !== 'undefined' ) {
                    var button = jQuery('#site-header .elementor-icon-list-items .elementor-icon-list-item:nth-child(2) a');
                    button.on( 'click', function() {
                        window.setTimeout(function(){
                            jQuery('.widget_product_search .aws-container .aws-search-field').focus();
                        }, 100);
                    } );
                }
            }, false);
        </script>
    
    <?php }

    You need to add it somewhere outside the plugins folder. For example, inside functions.php file of your theme or use some plugin for adding code snippets.

    Regards

    Thread Starter sparre

    (@sparretun)

    It works perfectly. What great support.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Automatically set focus to search field’ is closed to new replies.