Skip to content

Instantly share code, notes, and snippets.

@adesignl
Created May 14, 2013 20:04
Show Gist options
  • Save adesignl/5579031 to your computer and use it in GitHub Desktop.
Save adesignl/5579031 to your computer and use it in GitHub Desktop.
Hover State Script for Hubspot CTAs - Place after CTAs
<span class="hs-cta-node hs-cta-e4459cb8-88cc-4881-aed2-73d3e8c4f4fc" id="hs-cta-e4459cb8-88cc-4881-aed2-73d3e8c4f4fc" data-title="Click me!" data-img="/i/buttons/bgbutton_try.png" data-onimg="/i/buttons/bgbutton_ontry.png" >
<script>
(function(d) {
var customize = function(e) {
var target = e.target ? e.target : e.srcElement;
if(target && target.className == 'hs-cta-img'
&& !target.getAttribute('data-registered') && target.parentNode) {
var span = target.parentNode.parentNode;
target.title = span.getAttribute('data-title');
target.src = span.getAttribute('data-onimg');
target.onmouseover = function() {
target.src = span.getAttribute('data-onimg');
}
target.onmouseout = function() {
target.src = span.getAttribute('data-img');
}
target.setAttribute('data-registered',1);
}
}
if (d.addEventListener) {
d.addEventListener('mousemove', customize, false);
} else if (d.attachEvent) {
d.attachEvent('onmousemove', customize);
}
})(document);
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment