Skip to content

Instantly share code, notes, and snippets.

@devdame
Forked from dbc-challenges/jquery_example.html
Last active January 3, 2016 04:49
Show Gist options
  • Save devdame/8412075 to your computer and use it in GitHub Desktop.
Save devdame/8412075 to your computer and use it in GitHub Desktop.
Intro to jQuery for Phase 0
<!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">
<h2> My DBC Mascot </h2>
<img src="personal_site/img/fox6.png">
</div>
</body>
</html>
$(document).ready(function(){
//RELEASE 0:
//Link this script and the jQuery library to the jquery_example.html file and analyze what this code does.
//RELEASE 1:
//Add code here to select elements of the DOM
//RELEASE 2:
// Add code here to modify the css and html of DOM elements
$('body').css({'background-color': 'pink'})
$('h1').css({'color': '#ff007f'})
$('h1').css({'border': 'solid #ff007f 3px'})
$('h1').css({'visibility': 'hidden'})
$('h1').css({'visibility': 'visible'})
$('h2').html("The Noble Fox:")
//RELEASE 3: Event Listener
// Add the code for the event listener here
$('img')
.css({'border': 'solid #ff007f 25px'})
.on('mouseover', function(e){
e.preventDefault()
$(this).attr('src', 'http://fc02.deviantart.net/fs70/i/2012/359/3/7/derp_by_reptile_monster-d5p3nrh.jpg')
})
.on('mouseleave', function(e){
e.preventDefault()
$(this).attr('src', 'personal_site/img/fox6.png')
})
$( "img" ).click(function() {
$("img").animate({
'border-width': '100px'
}, 2000, function() {
});
});
//RELEASE 4 : Experiment on your own
}) // end of the document.ready function: do not remove or write DOM manipulation below this.
var bodyElement = $('body')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment