Skip to main content

How to make a box clickable

Custom code to make clicking a box click your chosen button

Jonathan Denney avatar
Written by Jonathan Denney
Updated this week

Ever find yourself needing an entire box to function like a button, where when clicked an action happens?

Here's how to do this with custom code:

Add the custom class

To make the box clickable, we'll need to mark it with a custom class.

To do that, click the section/row/column you want made clickable, and add this custom code:

clickable-box

Get the button element ID

Next, we'll need to copy the element ID of the button we want clicked, like so:

Add the custom code

Last, we'll need to add some custom code to the respective funnel step.

<script>
var clickableDiv = document.querySelector('.clickable-box');
var buttonToClick = document.querySelector('PASTE_ELEMENT_ID_HERE');

if (clickableDiv && buttonToClick) {
clickableDiv.style.cursor = 'pointer';

clickableDiv.onclick = function(e) {
buttonToClick.click();
};
};
</script>

Replace PASTE_ELEMENT_ID_HERE with the element ID you had copied (e.g #element123).

Here's where to add it. Click to manage your funnel, then to edit the funnel step, and add the custom code.

This will make the box with the custom class clickable, clicking your button of choice by the element's ID.

Did this answer your question?