$(function() {
var $elem = $('.js-resp');
var sp = '_sp.';
var pc = '_pc.';
var replaceWidth = 768;
function imgResp() {
var windowWidth = parseInt($(window).width());
$elem.each(function() {
var $this = $(this);
if(windowWidth >= replaceWidth) {
$this.attr('src', $this.attr('src').replace(sp, pc));
} else {
$this.attr('src', $this.attr('src').replace(pc, sp));
}
});
}
imgResp();
var resizeTimer;
$(window).on('resize', function() {
clearTimeout(resizeTimer);
resizeTimer = setTimeout(function() {
imgResp();
}, 200);
});
});