Skip to content

Instantly share code, notes, and snippets.

@nishinoshake
Last active May 29, 2016 05:08
Show Gist options
  • Save nishinoshake/17fef6581f5e914665f5 to your computer and use it in GitHub Desktop.
Save nishinoshake/17fef6581f5e914665f5 to your computer and use it in GitHub Desktop.
画像のPC/SP切り替え
function changeImage(){
var pcSuffix = '_pc',
spSuffix = '_sp',
breakPoint = 480;
$('.resimg').each(function(){
var $img = $(this);
if ( window.innerWidth < breakPoint ) {
$img.attr('src',$img.attr('src').replace(pcSuffix,spSuffix));
} else {
$img.attr('src',$img.attr('src').replace(spSuffix,pcSuffix));
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment