← All Scripts

#79 - Trigger Click onHover v0.1

Trigger a click event onHover.

Need help with this MemberScript?

All Memberstack customers can ask for assistance in the 2.0 Slack. Please note that these are not official features and support cannot be guaranteed.

View demo

<!-- 💙 MEMBERSCRIPT #79 v0.1 💙 HOVER BASED TABS -->
<script>
  document.addEventListener('DOMContentLoaded', function() {
    const hoverTabElements = document.querySelectorAll('[ms-code-onhover="click"]');

    hoverTabElements.forEach(hoverTabElement => {
      hoverTabElement.addEventListener('mouseenter', function() {
        hoverTabElement.click(); // Click on the element when hovering
      });
    });
  });
</script>
Description
Attribute
Click onHover
Trigger a click event when hovering over an element.
ms-code-onhover
click
click

Creating the Make.com Scenario

1. Download the JSON blueprint below to get stated.

2. Navigate to Make.com and Create a New Scenario...

3. Click the small box with 3 dots and then Import Blueprint...

4. Upload your file and voila! You're ready to link your own accounts.

How to Trigger a Click When a User Hovers Over an Element (Webflow)

Memberscripts needed

https://www.memberstack.com/scripts/79-click-onhover

Tutorial

Cloneable

Why/When would you need to Trigger a Click When a User Hovers Over an Element (Webflow)?

  1. Allow easier switching between certain elements like tabs.
  2. Provide a better user experience when comparing multiple elements.

If you’ve got users going back and forth between multiple tabs on a page, or maybe if you want to make comparing multiple elements smoother, you might want to make switching between them a bit easier by having your users just hover over elements instead of needing to click on them each time.

We’re going to see how we can use some very simple custom code to essentially perform clicks whenever users hover over specific elements.

Triggering a click when users hover over an element on a Webflow site

To trigger a click when users hover over an element in Webflow, we’re going to use MemberScript #79 – Trigger Click on Hover. Follow the link to get the code you’ll need to add to your page and watch a video tutorial on how to set everything up.

Setting it up

All you need to do is select whatever buttons you want users to just hover over and add the following attribute to them:

  • ms-code-onhover=”click”

Making it work

Now that you’ve added the attribute to your buttons, all you need to do is add the MemberScript #79 custom code to your page, before the closing body tag.

Conclusion

That’s everything, quick and easy as always. You can now go ahead and test the click on hover functionality on your live site.

If you want to use our demo project to get you started, just click the button below to add it to your Webflow site.

Our demo can help you easily turn a hover event into a click event.

Take me to the Scripts