Skip to content

Instantly share code, notes, and snippets.

@yh2n
Last active February 21, 2017 19:33
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 yh2n/4bb0a84dafeb5065e1ef3fe44b342153 to your computer and use it in GitHub Desktop.
Save yh2n/4bb0a84dafeb5065e1ef3fe44b342153 to your computer and use it in GitHub Desktop.
JS Bin // source https://jsbin.com/tahasug
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<style id="jsbin-css">
* {
box-sizing: border-box;
}
main {
padding: 30px;
min-width: 250px;
}
.hero {
height: 200px;
margin-bottom: 20px;
}
.hero img {
height: 100%
}
.thumbnail {
display: inline-block;
cursor: pointer;
height: 60px;
}
a.thumbnail:hover {
box-shadow: 5px 5px 5px gray;
}
.thumbnail img {
max-height: 100%;
}
</style>
</head>
<body>
<main>
<h1>Image Carousel</h1>
<div class="hero">
<img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/t-65/cat1.jpg" alt="" />
</div>
<div class="thumbnails">
<a class="thumbnail"><img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/t-65/cat1.jpg" alt="" /></a>
<a class="thumbnail"><img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/t-65/cat2.jpg" alt="" /></a>
<a class="thumbnail"><img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/t-65/cat3.jpg" alt="" /></a>
<a class="thumbnail"><img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/t-65/cat4.jpg" alt="" /></a>
</div>
<script src="https://code.jquery.com/jquery-3.1.0.js"></script>
</main>
<script id="jsbin-javascript">
// your code here
function displayImg () {
$(".thumbnail").click(function(event) {
var selection= $(event.currentTarget).find("img").attr("src");
$(".hero img").attr("src", selection);
})
}
$(function() {
displayImg();
});
</script>
<script id="jsbin-source-css" type="text/css">* {
box-sizing: border-box;
}
main {
padding: 30px;
min-width: 250px;
}
.hero {
height: 200px;
margin-bottom: 20px;
}
.hero img {
height: 100%
}
.thumbnail {
display: inline-block;
cursor: pointer;
height: 60px;
}
a.thumbnail:hover {
box-shadow: 5px 5px 5px gray;
}
.thumbnail img {
max-height: 100%;
}</script>
<script id="jsbin-source-javascript" type="text/javascript">// your code here
function displayImg () {
$(".thumbnail").click(function(event) {
var selection= $(event.currentTarget).find("img").attr("src");
$(".hero img").attr("src", selection);
})
}
$(function() {
displayImg();
});
</script></body>
</html>
* {
box-sizing: border-box;
}
main {
padding: 30px;
min-width: 250px;
}
.hero {
height: 200px;
margin-bottom: 20px;
}
.hero img {
height: 100%
}
.thumbnail {
display: inline-block;
cursor: pointer;
height: 60px;
}
a.thumbnail:hover {
box-shadow: 5px 5px 5px gray;
}
.thumbnail img {
max-height: 100%;
}
// your code here
function displayImg () {
$(".thumbnail").click(function(event) {
var selection= $(event.currentTarget).find("img").attr("src");
$(".hero img").attr("src", selection);
})
}
$(function() {
displayImg();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment