Creating a Back Button with Elementor

Creating a Back Button with Elementor

Adding buttons to your website makes navigation easier for visitors, including adding or creating a button to return to the previous page.

If you use WordPress and the Elementor plugin as your page builder, you can create a back button with Elementor without needing the paid version of the plugin, which will be discussed in this article.

How to Create a Back Button with Elementor

To do this, you must have the free or paid version of the Elementor plugin installed on your website, and ensure you understand the basics of using Elementor, such as adding specific elements.

If those two basic requirements are met, you can proceed to the steps for creating a back button with Elementor below:

1. Create the Button

The first thing you need to do is add a new button with Elementor, then in the Link option, leave it as a hash (#), and fill in the Text with whatever text you want to display.

Cara Membuat Tombol Kembali Dengan Elementor - 1-1

Next, open the Advanced tab while editing the button, and in the CSS Classes field, assign a class named tombol_kembali

Cara Membuat Tombol Kembali Dengan Elementor - 1-2

2. Add Custom HTML

Now you can add custom HTML at the very end of the page or post you are creating to add a script that returns to the previous page.

Cara Membuat Tombol Kembali Dengan Elementor - 2-1

After adding the custom HTML block, add the following line of code.

<script>document.addEventListener('DOMContentLoaded', function () {    let backButtons = document.querySelectorAll('.tombol_kembali');    backButtons.forEach(function (backButton) {        backButton.addEventListener('click', function (e) {            e.preventDefault();            history.back();        });    });});</script>

Once added, you can now save your post or page and test the button you just created.

Cara Membuat Tombol Kembali Dengan Elementor - 2-2

3. Test the Button

To test it, try opening the page that has the back button from another page, such as your website's homepage.

If successful, the result will look like this.

Cara Membuat Tombol Kembali Dengan Elementor - Animated

That is the easy way to create a back button with Elementor, and you certainly do not have to use Elementor Pro to create this button.

If you are interested in creating other buttons in Elementor, you might also be interested in this tutorial: How to Create a Back to Top Button in Elementor.

Written by

Muhammad Khoirun Nasikin

I enjoy tinkering with WordPress, hosting, VPS, web development, and various small experiments related to websites. I have over 3 years of experience in the web hosting industry.

COMMENTS

Loading...