Last active
August 29, 2015 14:21
-
-
Save tyrcho/9bb1525ede1a2093e878 to your computer and use it in GitHub Desktop.
Sample hover with card picture on mouse events
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> | |
<title> - cards hover demo</title> | |
<script type="text/javascript" src="http://code.jquery.com/jquery-1.6.2.js"> </script> | |
<style type="text/css"> | |
#image{ | |
position:absolute; | |
} | |
</style> | |
<script type="text/javascript">//<![CDATA[ | |
$(window).load(function(){ | |
function url(name) { | |
var address= "http://hearthstats.net/assets/cards/" + | |
name.replace(/ /g, "-").toLowerCase() + | |
".png"; | |
return address; | |
}; | |
$('div').hover((function() { | |
$(this).append($('<img>',{ | |
'id':'image', | |
'src': url($(this).text()) | |
})) ; | |
}), function() { | |
$(this).find('img:last').remove(); | |
}); | |
$(document).mousemove(function(e) { | |
$('#image').css({ | |
left: e.pageX, | |
top: e.pageY | |
}); | |
}); | |
}); | |
//]]> </script> | |
</head> | |
<body> | |
<div>Wrath</div> | |
<div>Wild Growth</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment