Skip to content

Instantly share code, notes, and snippets.

@LucaRosaldi
Created November 20, 2012 10:15
Show Gist options
  • Save LucaRosaldi/4117121 to your computer and use it in GitHub Desktop.
Save LucaRosaldi/4117121 to your computer and use it in GitHub Desktop.
jQuery: SVG fallback
.my-class {}
.svg .my-class { background:url(../img/graphic.svg); }
.no-svg .my-class { background:url(../img/graphic.png); }
<script src="jquery.js"></script>
<script src="modernizr.js"></script>
<script>
if(!Modernizr.svg) {
$('img[src*="svg"]').attr('src', function () {
return $(this).attr('src').replace('.svg', '.png');
});
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment