Created
June 5, 2013 21:17
-
-
Save mglaman/5717403 to your computer and use it in GitHub Desktop.
Using an element with a background-image, you can specify data-rollover="http://" to specify a rollover image.
This file contains 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
$(document).ready(function() { | |
$('.rollover').each(function() { | |
var rollover = $(this).data('rollover'); | |
var original = $(this).css('background-image'); | |
$(this).hover( | |
function() { | |
$(this).css('background-image', 'url('+rollover+')'); | |
}, | |
function() { | |
$(this).css('background-image', original); | |
}) | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment