Skip to content

Instantly share code, notes, and snippets.

@RCTumolac
Last active December 14, 2016 23:39
Show Gist options
  • Save RCTumolac/fd9afefd2aec140ac49abe3da949ee7d to your computer and use it in GitHub Desktop.
Save RCTumolac/fd9afefd2aec140ac49abe3da949ee7d to your computer and use it in GitHub Desktop.
Exported from Popcode. Click to import: https://popcode.org/?gist=fd9afefd2aec140ac49abe3da949ee7d
<!DOCTYPE html>
<html>
<head>
<title>jQuery Fun House Starter Code</title>
</head>
<body>
<div class="section">
<h1>What is your name?
<input id="name">
</h1>
<div>
<button id="submit-name" value="That’s my name">That’s my name</button>
</div>
<p id="greeting">Hi </p>
</div>
<div class="section">
<button id="change-color">Change the page's color!</button>
</div>
<div class="section" id="gallery">
<h1>Pictures of elephants</h1>
<img class="gallery-thumb" id="pic1" src="https://upload.wikimedia.org/wikipedia/commons/f/f9/Loxodonta_africana_-_old_bull_(Ngorongoro,_2009).jpg">
<img class="gallery-thumb" id="pic2" src="https://upload.wikimedia.org/wikipedia/commons/6/63/African_elephant_warning_raised_trunk.jpg">
<img class="gallery-thumb" id="pic3" src="https://iso.500px.com/wp-content/uploads/2014/08/2048-5.jpg">
<img class="gallery-thumb" id = "pic4" src = "https://aos.iacpublishinglabs.com/question/aq/700px-394px/zebra-kids_496f78e2c73055b.jpg?domain=cx.aos.ask.com">
<img class="gallery-thumb" id = "pic5" src = "http://media.buzzle.com/media/images-en/gallery/mammals/lions/900-139887669-lion-sitting-in-grasses.jpg">
<img class="gallery-thumb" id = "pic6" src = "https://www.sciencenews.org/sites/default/files/main/blogposts/wt_giraffeneck_free.jpg">
<img id="gallery-main" src="www.fake.com">
<p id = "HTML"></p>
</div>
</body>
</html>
{"enabledLibraries":["jquery"]}
var randomColors = ['red','blue','purple','gray','white','black'];
$("#submit-name").click(function(){
$("#greeting").html("Hi, " + $("#name").val());
$("#HTML").hide();
});
$("#pic1").click(function(){
$("#gallery-main").attr("src", "https://upload.wikimedia.org/wikipedia/commons/f/f9/Loxodonta_africana_-_old_bull_(Ngorongoro,_2009).jpg");
$("#HTML").hide();
});
$("#pic2").click(function(){
$("#gallery-main").attr("src", "https://upload.wikimedia.org/wikipedia/commons/6/63/African_elephant_warning_raised_trunk.jpg");
$("#HTML").hide();
});
$("#pic3").click(function(){
$("#gallery-main").attr("src", "https://iso.500px.com/wp-content/uploads/2014/08/2048-5.jpg");
$("#HTML").hide();
});
$("#pic4").click(function(){
$("#gallery-main").attr("src", "http://www.adamflanders.com/images/2013/herb_finds_out_hes_vegetarian.jpg");
$("#HTML").hide();
});
$("#pic5").click(function(){
$("#gallery-main").attr("src", "http://shortzilla.com/cartoons/cartoon-lion/cartoon-lion-eating-pizza.jpg");
$("#HTML").show();
$("#HTML").html("I am a lion, give me points or I will eat you!");
});
$("#pic6").click(function(){
$("#gallery-main").attr("src", "http://orig04.deviantart.net/cc3b/f/2014/027/2/6/derp_giraffe_by_mudkipbubble-d73y3b8.png");
$("#HTML").hide();
});
$("#change-color").click(function get_random_color() {
var letters = '0123456789ABCDEF'.split('');
var color = '#';
for (var i = 0; i < 6; i++ ) {
color += letters[Math.round(Math.random() * 15)];
}
$("body").css("background-color", color);
$("#HTML").hide();
});
#gallery {
width: 50%;
margin-left: auto;
margin-right: auto;
}
.gallery-thumb {
display: block;
float: left;
padding: 5px;
box-sizing: border-box;
width: 33%;
}
#change-color {
width: 300px;
text-align: center;
display: block;
margin: 0 auto;
font-size: 3em;
}
.section {
padding: 1em 0;
border-bottom: 2px dashed gray;
}
h1, #submit-name {
font-size: 2em;
}
input {
font-size: 1em;
}
#greeting {
text-align: center;
font-size: 2em;
text-shadow: 3px 3px 3px gray;
}
#gallery-main {
width: 100%;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment