Created
June 9, 2013 09:57
-
-
Save jswhisperer/5742999 to your computer and use it in GitHub Desktop.
Native Equivalents of Jquery Selectors
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
/* jQuery */ | |
$("div") | |
/* native equivalent */ | |
document.getElementsByTagName("div") | |
/* jQuery */ | |
$(".my-class") | |
/* native equivalent */ | |
document.querySelectorAll(".my-class") | |
/* FASTER native equivalent */ | |
document.getElementsByClassName("my-class") | |
/* jQuery */ | |
$(".my-class li:first-child") | |
/* native equivalent */ | |
document.querySelectorAll(".my-class li:first-child") | |
//----Get first by CSS selector---- | |
/* jQuery */ | |
$(".my-class").get(0) | |
/* native equivalent */ | |
document.querySelector(".my-class") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment