Skip to content

Instantly share code, notes, and snippets.

@yh2n
Created February 21, 2017 19:43
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/063387f51fc3aab3f8cd47bb8cd513e1 to your computer and use it in GitHub Desktop.
Save yh2n/063387f51fc3aab3f8cd47bb8cd513e1 to your computer and use it in GitHub Desktop.
JS Bin // source https://jsbin.com/gurimog
<!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;
font-family: sans-serif;
}
main {
max-width: 960px;
margin: 0 auto;
min-width: 250px;
padding: 30px;
}
.lightbulb {
border: 1px solid grey;
padding: 10px;
width: 25%;
float: left;
cursor: pointer;
}
.lightbulb img {
width: 100%;
}
.bulb-on {
background-color: yellow;
}
</style>
</head>
<body>
<main>
<div>
<div class="lightbulb js-lightbulb">
<img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/t-65/lightbulb.svg" alt="Kiwi standing on oval">
</div>
<div class="lightbulb js-lightbulb">
<img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/t-65/lightbulb.svg" alt="Kiwi standing on oval">
</div>
</div>
<div class="lightbulb js-lightbulb">
<img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/t-65/lightbulb.svg" alt="Kiwi standing on oval">
</div>
<div class="lightbulb js-lightbulb">
<img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/t-65/lightbulb.svg" alt="Kiwi standing on oval">
</div>
</div>
</main>
<script src="https://code.jquery.com/jquery-3.1.0.js"></script>
<script id="jsbin-javascript">
// your code here
function handleClicks() {
$(".lightbulb").click(function(event){
$(".lightbulb").removeClass("bulb-on");
$(this).addClass("bulb-on")
});
}
$(function() {
handleClicks();
});
</script>
<script id="jsbin-source-css" type="text/css">* {
box-sizing: border-box;
font-family: sans-serif;
}
main {
max-width: 960px;
margin: 0 auto;
min-width: 250px;
padding: 30px;
}
.lightbulb {
border: 1px solid grey;
padding: 10px;
width: 25%;
float: left;
cursor: pointer;
}
.lightbulb img {
width: 100%;
}
.bulb-on {
background-color: yellow;
}
</script>
<script id="jsbin-source-javascript" type="text/javascript">// your code here
function handleClicks() {
$(".lightbulb").click(function(event){
$(".lightbulb").removeClass("bulb-on");
$(this).addClass("bulb-on")
});
}
$(function() {
handleClicks();
});</script></body>
</html>
* {
box-sizing: border-box;
font-family: sans-serif;
}
main {
max-width: 960px;
margin: 0 auto;
min-width: 250px;
padding: 30px;
}
.lightbulb {
border: 1px solid grey;
padding: 10px;
width: 25%;
float: left;
cursor: pointer;
}
.lightbulb img {
width: 100%;
}
.bulb-on {
background-color: yellow;
}
// your code here
function handleClicks() {
$(".lightbulb").click(function(event){
$(".lightbulb").removeClass("bulb-on");
$(this).addClass("bulb-on")
});
}
$(function() {
handleClicks();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment