Skip to content

Instantly share code, notes, and snippets.

@dstyle0210
Last active August 29, 2015 14:04
Show Gist options
  • Select an option

  • Save dstyle0210/5255dba4708e54d2ab88 to your computer and use it in GitHub Desktop.

Select an option

Save dstyle0210/5255dba4708e54d2ab88 to your computer and use it in GitHub Desktop.
이미지 온오프 함수
//jQuery Extend image OnOff : dstyle
//이미지 배열에서 특정 인덱스만 온으로 바꿈.
(function($){
$.fn.onoff = function(opt){
var o={
idx:0,
ext:"gif",
sep:"On"
};
(($.type(opt)=="object")?$.extend(o,opt):(o.idx = opt+""));
this.each(function(n,m){
m.src = (m.src).replace(o.sep+"."+o.ext,"."+o.ext);
if(n==o.idx){
m.src = (m.src).replace("."+o.ext,o.sep+"."+o.ext);
};
});
};
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment