Created
January 13, 2017 14:07
-
-
Save caulfield/fd17c67879ada1d1597c942e380285f8 to your computer and use it in GitHub Desktop.
DOM events
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> | |
<script | |
src="https://code.jquery.com/jquery-3.1.1.min.js" | |
integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8=" | |
crossorigin="anonymous"></script> | |
<script | |
src="index.js"></script> | |
</head> | |
<body class="wrapper"> | |
<h1>My First Heading</h1> | |
<p>My first paragraph.</p> | |
</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
console.log('before document ready') | |
console.debug('is body', $('body').length == 1) | |
console.debug('is nested', $('h1').length == 1) | |
console.debug('is document', $(document).length == 1) | |
console.debug('is document.body', $(document.body).length == 1) | |
$('body').mouseenter(function() { | |
console.log('hover attached on body BEFORE document ready'); | |
}); | |
$(document).ready(function() { | |
console.log('after document ready') | |
console.debug('is body', $('body').length == 1) | |
console.debug('is nested', $('h1').length == 1) | |
console.debug('is document', $(document).length == 1) | |
console.debug('is document.body', $(document.body).length == 1) | |
$('body').mouseenter(function() { | |
console.log('hover attached on body AFTER document ready'); | |
}); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment