-
-
Save Oppenheimer1/9560369 to your computer and use it in GitHub Desktop.
Intro to jQuery for Phase 0
This file contains hidden or 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 lang="en"> | |
| <head> | |
| <title>DOM manipulation with jQuery</title> | |
| </head> | |
| <body> | |
| <h1> Hello. Welcome to the jQuery DOM Manipulation Challenge! </h1> | |
| <h2>Now you see me.</h2> | |
| <div class="mascot"> | |
| <h1 class="dfly"> My DBC Mascot </h1> | |
| <img src="dbc_logo.jpg"> | |
| </div> | |
| <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script> | |
| <script type="text/javascript" src="jquery_example.js"></script> | |
| </body> | |
| </html> |
This file contains hidden or 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': '#CEECF5'}) | |
| //RELEASE 1: | |
| //Add code here to select elements of the DOM | |
| var bodyElement = $('body'); | |
| var bodyElement = $('h1'); | |
| var mascot = $('.mascot'); | |
| //RELEASE 2: | |
| // Add code here to modify the css and html of DOM elements | |
| $( "h1" ).on( "mouseover", function() { | |
| $( this ).css( "color", "white" ); | |
| }); | |
| $( "h1" ).on( "mouseover", function() { | |
| $( this ).css( "border", "thin solid black" ); | |
| }); | |
| $( "h2" ).on( "mouseover", function() { | |
| $( this ).css( "visibility", "hidden" ); | |
| }); | |
| $( "h1.dfly" ).on( "mouseover", function() { | |
| $( this ).html("DRAGONFLIES"); | |
| }); | |
| //RELEASE 3: Event Listener | |
| // Add the code for the event listener here | |
| $('img').on('mouseover', function(e){ | |
| e.preventDefault() | |
| $(this).attr('src', 'img/dragonflies.jpg') | |
| }) | |
| $('img').on('mouseleave', function(e){ | |
| e.preventDefault() | |
| $(this).attr('src', 'img') | |
| }) | |
| //RELEASE 4 : Experiment on your own | |
| $("img").mouseover(function(){ | |
| $(this).animate({ | |
| height:'300px', | |
| width:'600px', | |
| left : '-11px' | |
| }) | |
| }); | |
| $("img").mouseout(function(){ | |
| $(this).animate({ | |
| height:'20px', | |
| width:'20px', | |
| left : '0px' | |
| }) | |
| }); | |
| }) // 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