This workaround shows a different element when a visitor hovers over part of your page. Use it to swap one image for another on hover, show text over an image, or display a tooltip or hint next to a button.
See the demo page built in Unbounce.
This is community code, not an official Unbounce feature. Unbounce Support can't troubleshoot custom code. Test it on a published page before relying on it, and work with a developer if you aren't comfortable editing HTML, JavaScript, and CSS.
How it works
You add every element you want to show on hover to the page, then hide them with CSS. The script shows each hidden element when the visitor hovers over the element you choose.
Scripts and video tutorials
- Tooltips use the tooltip scripts. See the video tutorial.
- Rollover images use the rollover image scripts, covered in the same video.
Set up the effect
-
Add the elements to the page.
- For a rollover image, stack two elements on top of each other, such as two images or boxes. The bottom element shows when the page loads, and the top element appears on hover. You can usually make two images exactly the same size with a mask, even if their proportions differ.
- For a tooltip, place the element that appears on hover next to the element it explains, for example beside or below a button. To show both an image and text, put them in a box and show and hide the box.
- Add jQuery to the page with a new script in the JavaScripts section containing the following:
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script>
- Add the script you need to the JavaScripts section with placement set to Before Body End Tag. Use
on-hover-image-swapfor rollover images and text, oron-hover-show-hidefor tooltips. - In the variables at the top of the script, replace the IDs with the IDs of your elements.
- Add the following CSS to the Stylesheets section to hide the elements that appear on hover:
<style>
#lp-pom-image-9 {
display: none;
}
</style>
Replace #lp-pom-image-9 with the ID of your element. To hide more than one element, list the IDs separated by commas.
- Save and republish the page.
Test the change
Run an A/B test with a small share of traffic to confirm the change doesn't lower your conversion rate.