Back button jQuery/CSS

Hi there,

I’m trying to add a jQuery, javascript or css to my button enabling the function going back in history.

I’ve tried searching and adding functions like window.history.back() or history.go(1).
I’m certain this will work, just cannot find the right way of adding it to the button.

Hello @vojtechzikmund,

Thanks for writing in!

To resolve your issue, please do the following:

1.) Add a back-button class to your button element.

2.) And then use this custom JS:

(function($){
	$('.back-button').on('click touchstart', function(e){
		e.preventDefault();
    	history.back(1);
	});
})(jQuery);

We would love to know if this has worked for you. Thank you.

1 Like

Thanks! Worked like a charm :slight_smile:

You’re welcome!
We’re glad we were able to help you out.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.