How to make a button redirect to another page using jQuery or just Javascript

is this what you mean?

$('button selector').click(function(){
   window.location.href='the_link_to_go_to.html';
})

$('#someButton').click(function() {
    window.location.href = '/some/new/page';
    return false;
});

Without script:

<form action="where-you-want-to-go"><input type="submit"></form>

Better yet, since you are just going somewhere, present the user with the standard interface for "just going somewhere":

<a href="where-you-want-to-go">ta da</a>

Although, the context sounds like "Simulate a normal search where the user submits a form", in which case the first option is the way to go.


In your html, you can add data attribute to your button:

<button type="submit" class="mybtn" data-target="/search.html">Search</button>

Then you can use jQuery to change the url:

$('.mybtn').on('click', function(event) {
    event.preventDefault(); 
    var url = $(this).data('target');
    location.replace(url);
});

Hope this helps


With simple Javascript:

<input type="button" onclick="window.location = 'path-here';">