Created
February 18, 2014 16:53
-
-
Save madzak/9074840 to your computer and use it in GitHub Desktop.
Jquery Conversion
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
$(function(){ | |
$('#variations-test .swatches a').hover(function(){ | |
$('#variations-test .variation-color').html( $(this).attr('data-color') ); | |
}, function() { | |
$('#variations-test .variation-color').html( $('#variations-test .swatches a.active').attr('data-color') ); | |
}); | |
}); |
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
var variations = document.getElementById('variations-test'), | |
swatchLinks = variations.querySelectorAll('.swatches a'), | |
variationColor = variations.querySelector('.variation-color'); | |
for(var i=0; i< swatchLinks.length; i++) { | |
swatchLinks[i].addEventListener('mouseenter', function(evt) { | |
variationColor.innerHTML = this.getAttribute('data-color'); | |
}); | |
swatchLinks[i].addEventListener('mouseleave', function(evt) { | |
var active = variations.querySelector('.swatches a.active'); | |
variationColor.innerHTML = active.getAttribute('data-color'); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment