Skip to content

Instantly share code, notes, and snippets.

@naoyeye
Created July 3, 2015 18:08
Show Gist options
  • Save naoyeye/d6c445e7ba7a86a1fdbd to your computer and use it in GitHub Desktop.
Save naoyeye/d6c445e7ba7a86a1fdbd to your computer and use it in GitHub Desktop.
png - gif
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>test</title>
<style type="text/css">
.image {
display: inline-block;
width: 150px;
}
img {
max-width: 100%;
}
</style>
</head>
<body>
<a href="###" class="image fit thumb">
<img class="giff" src="http://t.wdjcdn.com/upload/mkt-campaign/test/demo1.png" alt="" />
</a>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script type="text/javascript">
$(function () {
$(".giff").hover(
function () {
var src = $(this).attr("src");
$(this).attr("src", src.replace(/\.png$/i, ".gif"));
},
function () {
var src = $(this).attr("src");
$(this).attr("src", src.replace(/\.gif$/i, ".png"));
}
);
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment