Skip to content

Instantly share code, notes, and snippets.

@kohki-shikata
Created November 12, 2015 03:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kohki-shikata/c53176a04ef37bab4c69 to your computer and use it in GitHub Desktop.
Save kohki-shikata/c53176a04ef37bab4c69 to your computer and use it in GitHub Desktop.
jQuery Roll Over
// img roll over
$(function(){
$("img[src*='_on']").addClass("current");
$("img,input[type='image']").hover(function(){
if ($(this).attr("src")){
$(this).attr("src",$(this).attr("src").replace("_off.", "_on."));
}
},function(){
if ($(this).attr("src") && !$(this).hasClass("current") ){
$(this).attr("src",$(this).attr("src").replace("_on.", "_off."));
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment