• Resolved malavigne

    (@malavigne)


    Hi there,
    I’m displaying my results using Ajax and I was wondering if there was a way to link back to the top of the page right after clicking the search button?

    I have a very specific need. My search bar is under the div were the results will display. My results are at the top of my page, so I would like the page to automatically scroll up to show the very first result.

    Can you help me with that?

    Thanks a lot for your good plugin and the great support!

    https://wordpress.org/plugins/ultimate-wp-query-search-filter/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author TC.K

    (@wp_dummy)

    Well, you can use javascript to do it.
    Let say you want to scroll back to <div id="main">..</div>.
    Insert this code in the header (after wp_head()) or footer:

    <script type="text/javascript">
    	jQuery(document).ready(function($) {
    		$( '.usfbtn' ).click(function() {
    		  $('html, body').animate({
    		    scrollTop: $("#main").offset().top
    		}, 1000);
           });
    })
    </script>

    You can change the ‘#main’ to the div you like.

    Thread Starter malavigne

    (@malavigne)

    You are great sir! Thanks a lot!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Back to top after search’ is closed to new replies.