Skip to content

Instantly share code, notes, and snippets.

@jlee42
Created July 13, 2012 15:41
Show Gist options
  • Save jlee42/3105570 to your computer and use it in GitHub Desktop.
Save jlee42/3105570 to your computer and use it in GitHub Desktop.
Unobtrusive JavaScript implementation of :mouseover for Rails 4.0 (jQuery)
$(document).ready(function(){
$('img[data-mouseover]').hover(function() {
$(this).data('_mouseover', $(this).attr('src'));
$(this).attr('src', $(this).data('mouseover'));
},function() {
$(this).attr('src', $(this).data('_mouseover'));
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment