Last active
October 11, 2015 22:21
-
-
Save tylucaskelley/b9b868ce4ad6cf22c764 to your computer and use it in GitHub Desktop.
Udacity jQuery Webcast: When Does Sizzle Get Used?
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() { | |
// Sizzle is jQuery's internal library for DOM element selection. When does it actually get used? | |
// modern browser, i.e. Chrome, Firefox, Safari, IE 8+, Edge | |
$("#title"); // Nope! --> document.getElementById("title"); | |
$(".my-class") // Nope! --> document.getElementsByClassName("my-class"); | |
$("body > div.foo #element"); // Nope! --> document.querySelectorAll("body > div.foo #element"); | |
// IE 6,7 and other outdated browsers | |
$("#title"); // Nope! --> document.getElementById("title"); | |
$(".my-class") // Nope! --> document.getElementsByClassName("my-class"); | |
$("body > div.foo #element"); // Yes! Here, we need Sizzle, since we don't have the querySelectorAll function. | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment