Skip to content

Instantly share code, notes, and snippets.

Created September 8, 2015 18:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/b47e2765c4ff215c7da8 to your computer and use it in GitHub Desktop.
Save anonymous/b47e2765c4ff215c7da8 to your computer and use it in GitHub Desktop.
Practice Refactoring to jQuery Practice Refactoring to jQuery // source https://jsbin.com/mawase
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="Practice Refactoring to jQuery">
<script src="http://code.jquery.com/jquery-2.1.1.min.js"></script>
<meta charset="utf-8">
<title>Practice Refactoring to jQuery</title>
<style id="jsbin-css">
#refrigerator {
background-color: #FFFFFF;
width: 200px;
border: 5px solid #333333;
}
#refrigerator img {
width: 100px;
display: block;
margin: 30px auto;
}
</style>
</head>
<body>
<div id="refrigerator">
<div class="oranges">
<img src="https://whydyoueatthat.files.wordpress.com/2011/12/oranges-vitamin-c-lg.jpg">
</div>
<div class="apples">
<img src="http://lymanorchards.com/files/7013/6725/1487/apples.jpg">
</div>
</div>
<script id="jsbin-javascript">
$(document).ready(function() {
alert("Pick a healthy snack from the refrigerator!");
});
$('.oranges').click(function(){
$(this).css('border', '5px solid orange');
alert('You chose an orange!');
});
$('.apples').click(function(event){
$(this).css('border', '5px solid red');
alert('You chose an apple!');
});
</script>
<script id="jsbin-source-html" type="text/html"><!DOCTYPE html>
<html>
<head>
<meta name="description" content="Practice Refactoring to jQuery">
<script src="//code.jquery.com/jquery-2.1.1.min.js"><\/script>
<meta charset="utf-8">
<title>Practice Refactoring to jQuery</title>
</head>
<body>
<div id="refrigerator">
<div class="oranges">
<img src="https://whydyoueatthat.files.wordpress.com/2011/12/oranges-vitamin-c-lg.jpg">
</div>
<div class="apples">
<img src="http://lymanorchards.com/files/7013/6725/1487/apples.jpg">
</div>
</div>
</body>
</html></script>
<script id="jsbin-source-css" type="text/css">#refrigerator {
background-color: #FFFFFF;
width: 200px;
border: 5px solid #333333;
}
#refrigerator img {
width: 100px;
display: block;
margin: 30px auto;
}</script>
<script id="jsbin-source-javascript" type="text/javascript">
$(document).ready(function() {
alert("Pick a healthy snack from the refrigerator!");
});
$('.oranges').click(function(){
$(this).css('border', '5px solid orange');
alert('You chose an orange!');
});
$('.apples').click(function(event){
$(this).css('border', '5px solid red');
alert('You chose an apple!');
});
</script></body>
</html>
#refrigerator {
background-color: #FFFFFF;
width: 200px;
border: 5px solid #333333;
}
#refrigerator img {
width: 100px;
display: block;
margin: 30px auto;
}
$(document).ready(function() {
alert("Pick a healthy snack from the refrigerator!");
});
$('.oranges').click(function(){
$(this).css('border', '5px solid orange');
alert('You chose an orange!');
});
$('.apples').click(function(event){
$(this).css('border', '5px solid red');
alert('You chose an apple!');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment