Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 39 additions & 34 deletions boxes.html
Original file line number Diff line number Diff line change
@@ -1,38 +1,43 @@
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="http://code.jquery.com/jquery-2.1.4.min.js"></script>
<script type="text/javascript" src="boxes.js"></script>
<link rel="stylesheet" type="text/css" href="style.css">
<title>Boxes!</title>
</head>
<body>
<div id="container">
<div id="row1" class="row">
<div class="box boxType1"></div>
<div class="box boxType2"></div>
<div class="box boxType3"></div>
<div class="box boxType1"></div>
</div>
<div id="row2" class="row">
<div class="box boxType2"></div>
<div class="box boxType3"></div>
<div class="box boxType1"></div>
<div class="box boxType2"></div>
</div>
<div id="row3" class="row">
<div class="box boxType3"></div>
<div id="secretBox" class="box boxType1"></div>
<div class="box boxType2"></div>
<div class="box boxType3"></div>
</div>
<div id="row4" class="row">
<div class="box boxType1"></div>
<div class="box boxType2"></div>
<div class="box boxType3"></div>
<div class="box boxType1"></div>
</div>
</div>
</body>
<head>
<script type="text/javascript" src="http://code.jquery.com/jquery-2.1.4.min.js"></script>
<script>
$(document).ready(function () {
console.log("ready!");
});
</script>
<script type="text/javascript" src="boxes.js"></script>
<link rel="stylesheet" type="text/css" href="style.css">
<title>Boxes!</title>
</head>
<body>
<div id="container">
<div id="row1" class="row">
<div class="box boxType1"></div>
<div class="box boxType2"></div>
<div class="box boxType3"></div>
<div class="box boxType1"></div>
</div>
<div id="row2" class="row">
<div class="box boxType2"></div>
<div class="box boxType3"></div>
<div class="box boxType1"></div>
<div class="box boxType2"></div>
</div>
<div id="row3" class="row">
<div class="box boxType3"></div>
<div id="secretBox" class="box boxType1"></div>
<div class="box boxType2"></div>
<div class="box boxType3"></div>
</div>
<div id="row4" class="row">
<div class="box boxType1"></div>
<div class="box boxType2"></div>
<div class="box boxType3"></div>
<div class="box boxType1"></div>
</div>
</div>
</body>

</html>
41 changes: 40 additions & 1 deletion boxes.js
Original file line number Diff line number Diff line change
@@ -1 +1,40 @@
console.log("hello world");
// Exercise 2

$('#secretBox').append('<h1>secret box!</h1>');
$('#row1').children().addClass('boxType3');
$('#row4 > div:last-child').hide();
$('div.box.boxType1').css('backgound-color', 'white');
$('#row2 > div:lt(2)').removeAttr('style');
$('#row2 > div:lt(2)').removeAttr('class');
$('.box').not(document.getElementById("secretBox"))
.css("width", "2px");
$('<img src = "https://s-media-cache-ak0.pinimg.com/736x/c2/3d/f8/c23df8d247f509c4b1d680dd5406f325.jpg">');
// Exercise 3
// 1.
$('#container').click(function(event) {
console.log("X: " + event.pageX + " Y: " + event.pageY);
});

// 2.
$('div.box.boxType1').append('<a href = "https://www.galvanize.com">Galvanize</a>').click(function(event) {
alert("You can never leave the page.");
event.preventDefault();
});

// 3.
$('.box').click(function(event) {
$('.box').append('<img src = "https://s-media-cache-ak0.pinimg.com/736x/c2/3d/f8/c23df8d247f509c4b1d680dd5406f325.jpg" width= 100%>');
});
$('.box').click(function(event) {
$('.box').empty();
});

//4.
$("#container").click(function(event) {
if ($(event.target).is($(this))) {
$(this).css("background-color", "limegreen");
} else {
$(event.target).css("background-color", "white");
$(this).css("background-color", "black");
}
});