Created
May 22, 2014 23:27
-
-
Save brettsnippets/4a000877c0eb29a14e08 to your computer and use it in GitHub Desktop.
Cross Browser SVG
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
<img data-png="potato.png" data-svg="potato.svg"> | |
<noscript><img src="potato.png" alt="Heyo, my potato!"></noscript> | |
<script> | |
if (!Modernizr.svg) { | |
$('img[data-svg$=svg]').each(function(index, item) { | |
var png = $(item).attr('data-png'); | |
$(item).attr('src', png); | |
}); | |
} else { | |
$('img[data-svg$=svg]').each(function(index, item) { | |
var svg = $(item).attr('data-svg'); | |
$(item).attr('src', svg); | |
}); | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment