Skip to content

Instantly share code, notes, and snippets.

@LadyMozzarella
Forked from dbc-challenges/jquery_example.html
Last active January 2, 2016 18:09
Show Gist options
  • Save LadyMozzarella/8341563 to your computer and use it in GitHub Desktop.
Save LadyMozzarella/8341563 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">
<h1> My DBC Mascot </h1>
<img src="logo.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.
$('body').css({'background-color': '#400D12'})
//!!!!RELEASE 1:
//Add code here to select elements of the DOM
var bodyElement = $('body')
var headings1 = $('h1')
var mascotHeader = $('.mascot h1')
var mascotImg = $('.mascot img')
headings1.css({'color': '#F73434'})
bodyElement.css({'text-align': 'center'})
mascotHeader.css({'color': '#0E8A84'})
//RELEASE 2:
// Add code here to modify the css and html of DOM elements
//{Color changed above ^^}
headings1.css({'border' : '1px solid #0BB057'})
headings1.css({'visibility' : 'inherit'})
$('.mascot h1').html("Banana Slug")
//RELEASE 3: Event Listener
// Add the code for the event listener here
$('img').on({
mouseenter: function(e) {
e.preventDefault()
$(this).attr('src', 'sluggie.png')
},
mouseleave: function(e) {
$(this).attr('src', 'logo.png')
}
})
//RELEASE 4 : Experiment on your own
bodyElement.css({'margin': '0 0'})
headings1.on( "mouseover", function() {
$( this ).css({'color': '#0E8484'});
})
headings1.on( "mouseleave", function() {
$( this ).css({'color' : "#F73434"});
})
mascotHeader.on( "mouseover", function() {
$( this ).css({'color': '#F73434'});
})
mascotHeader.on( "mouseleave", function() {
$( this ).css({'color' : "#0E8484"});
})
headings1.css({'font-family': 'Georgia, serif', 'background-color': '#F0BA0C', 'height': '100%s', 'box-shadow': '0 4px 20px #0E8A84', 'font-size': '4em'})
mascotImg.css({'margin-top': '5%', 'border': '5px double #0E8A84'})
}) // 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