Created
May 14, 2013 20:04
-
-
Save adesignl/5579031 to your computer and use it in GitHub Desktop.
Hover State Script for Hubspot CTAs - Place after CTAs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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" > |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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