Created
February 3, 2011 08:30
-
-
Save Takazudo/809205 to your computer and use it in GitHub Desktop.
do preload using custom data attr.
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
<img | |
src="hogehoge_on.png" | |
data-srcoff="hogehoge_off.png" | |
data-preloadattr="srcoff" | |
alt="" | |
/> |
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(){ | |
$('img[data-preloadattr]').each(function(){ | |
var $el = $(this); | |
var attr = $el.data('preloadattr'); | |
(new Image).src = $el.data(attr); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment