-
-
Save wiltonmaddams/8410557 to your computer and use it in GitHub Desktop.
Intro to jQuery for Phase 0
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>DOM manipulation with jQuery</title> | |
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> | |
<script type="text/javascript" src="jquery_example.js"></script> | |
</head> | |
<body> | |
<h1> Hello. Welcome to the jQuery DOM Manipulation Challenge! </h1> | |
<div class="mascot"> | |
<h1 class="foxes"> My DBC Mascot </h1> | |
<img src="http://scm-l3.technorati.com/12/12/13/73853/devbootcamp.png?t=20121213131231"> | |
</div> | |
<div id="clickme"><a href="#clickme"> | |
Click here to watch the animation!</a> | |
</div> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready(function(){ | |
//RELEASE 0: | |
//Link this script and the jQuery library to the jquery_example.html file and analyze what this code does. | |
$('body').css({'background-color': 'pink'}); | |
//RELEASE 1: | |
//Add code here to select elements of the DOM | |
var bodyElement = $("body"); | |
var h1Element = $("h1"); | |
var classElement = $(".mascot"); | |
var image = $("img"); | |
var button =$('a'); | |
//RELEASE 2: | |
h1Element.css({'font-family': 'Arial', 'border': '12px groove #123456', 'color': '#A12456', 'background-color': '#fff', 'visibility': 'visible'}); | |
button.css({'display':'inline','background-color': 'lightblue', 'border': '2px groove #123456', 'font-family':'Arial', 'padding': '5px', 'text-decoration': 'none'}); | |
classElement.html('<h1>Foxes 2014</h1><img src="http://scm-l3.technorati.com/12/12/13/73853/devbootcamp.png?t=20121213131231">'); | |
classElement.css({'font-family': 'Arial', 'border': '12px groove #123456', 'color': '#A12456', 'background-color': '#fff', 'visibility': 'visible', 'font-size': '1.000em', 'margin-bottom': '32px'}); | |
$("img").css({'border': '2px solid #123456'}) | |
//RELEASE 3: Event Listener | |
// Add the code for the event listener here | |
$('img').on('mouseover', function(e){ | |
e.preventDefault(); | |
$(this).attr('src', 'http://www.state.nj.us/dep/fgw/images/wildlife/fox_glsm.jpg'); | |
}); | |
$('img').on('mouseleave', function(e) { | |
e.preventDefault(); | |
$(this).attr('src', 'http://scm-l3.technorati.com/12/12/13/73853/devbootcamp.png?t=20121213131231'); | |
}); | |
//RELEASE 4 : Experiment on your own | |
$( "#clickme" ).click(function() { | |
$( "img" ).animate({ | |
width: "45%", | |
opacity: 0.5, | |
marginTop: "10%", | |
marginLeft: "20%", | |
marginBottom: "10%", | |
borderLeftWidth: "24px", | |
borderRightWidth: "2px", | |
borderTopWidth: "12px", | |
borderBottomWidth: "2px", | |
}, 1500 ) | |
.animate({ | |
opacity: 1, | |
borderWidth: "22px", | |
}, 1000 ) | |
.animate({ | |
width:0, | |
borderWidth: "0px", | |
opacity: 0, | |
}, 1500 ); | |
}); | |
}); // end of the document.ready function: do not remove or write DOM manipulation below this. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment