From f611a9910896aeb79f26e5f5dd2c8d87d1aa3289 Mon Sep 17 00:00:00 2001 From: Brad Butterfield Date: Tue, 16 Feb 2016 11:51:29 -0700 Subject: [PATCH 1/3] Exercise 1 - DOM Ready --- boxes.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/boxes.js b/boxes.js index 6b2b3db..f4a4153 100644 --- a/boxes.js +++ b/boxes.js @@ -1 +1,9 @@ -console.log("hello world"); +//console.log("hello world"); + +$( document ).ready(function() { + alert("I am ready for DOM manipulation"); +}); + +$(function() { + alert("Callback style 2: I am ready for DOM manipulation"); +}); From 58313809fe82fe7b58039cb812c69365a4a1ee42 Mon Sep 17 00:00:00 2001 From: Brad Butterfield Date: Tue, 16 Feb 2016 12:46:37 -0700 Subject: [PATCH 2/3] Exercise 2 - Selectors, CSS, Attributes --- boxes.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/boxes.js b/boxes.js index f4a4153..30cb88a 100644 --- a/boxes.js +++ b/boxes.js @@ -1,9 +1,10 @@ -//console.log("hello world"); - $( document ).ready(function() { - alert("I am ready for DOM manipulation"); -}); + alert( 'I am ready for DOM manipulation' ); + $( '#secretBox' ).css({ 'background-color': 'white' }).append( '

secret box!

' ); + $( '#row1 > div' ).addClass( 'boxType3' ).removeClass( 'boxType1' ); + $( '#row4 > div:last-child' ).css({ 'display': 'none' }); + $( '.boxType1' ).css({ 'background-color': 'white' }); + $( '#row2 > div:nth-child(-n+2)' ).css({ 'all': 'unset' }); + $( '#container > .row > .box:not(#secretBox)' ).css({ 'width': '2px' }); -$(function() { - alert("Callback style 2: I am ready for DOM manipulation"); }); From 90589b1a3cac5469cc57a7d3081206911d73eb61 Mon Sep 17 00:00:00 2001 From: Brad Butterfield Date: Thu, 18 Feb 2016 23:47:10 -0700 Subject: [PATCH 3/3] Exercise 3 - Events --- boxes.js | 55 +++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 47 insertions(+), 8 deletions(-) diff --git a/boxes.js b/boxes.js index 30cb88a..12c2ad0 100644 --- a/boxes.js +++ b/boxes.js @@ -1,10 +1,49 @@ -$( document ).ready(function() { - alert( 'I am ready for DOM manipulation' ); - $( '#secretBox' ).css({ 'background-color': 'white' }).append( '

secret box!

' ); - $( '#row1 > div' ).addClass( 'boxType3' ).removeClass( 'boxType1' ); - $( '#row4 > div:last-child' ).css({ 'display': 'none' }); - $( '.boxType1' ).css({ 'background-color': 'white' }); - $( '#row2 > div:nth-child(-n+2)' ).css({ 'all': 'unset' }); - $( '#container > .row > .box:not(#secretBox)' ).css({ 'width': '2px' }); +$(document).ready(function() { + alert('I am ready for DOM manipulation'); + // $( '#secretBox' ).css({ 'background-color': 'white' }).append( '

secret box!

' ); + // $( '#row1 > div' ).addClass( 'boxType3' ).removeClass( 'boxType1' ); + // $( '#row4 > div:last-child' ).css({ 'display': 'none' }); + // $( '.boxType1' ).css({ 'background-color': 'white' }); + // $( '#row2 > div:nth-child(-n+2)' ).css({ 'all': 'unset' }); + // $( '#container > .row > .box:not(#secretBox)' ).css({ 'width': '2px' }); + + $('#container').click(function(cord) { + var offset = $(this).offset(); + var x = (cord.pageX - offset.left); + var y = (cord.pageY - offset.top); + console.log("X: " + x + " Y: " + y); + }); + + $('.boxType1').append('Galvanize'); + $('.boxType1 a').click(function() { + alert('You can never leave this page'); + return false; + }); + + $('div.box').click(function() { + if ($(this).css('background-image') == 'none') { + $(this).css({ + 'background-image': 'url("http://cdn.hasinstinct.com/2015/08/12/white-cute-puppy-jpg.jpg")', + 'background-size': '154px 154px' + }); + } else { + $(this).removeAttr("style"); + } + }); + + $('#container').click(function() { + if (event.target == this) { + $(this).css({ + 'background-color': 'limeGreen' + }); + } else { + $(event.target).css({ + 'background-color': 'white' + }); + $(this).css({ + 'background-color': 'black' + }); + } + }); });