Created
March 20, 2014 19:05
-
-
Save onestepcreative/9671405 to your computer and use it in GitHub Desktop.
javascript selector not requiring jQuery
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
| var S = function (selector, context) { | |
| if (typeof selector === 'string') { | |
| if (context) { | |
| var cont; | |
| if (context.jquery) { | |
| cont = context[0]; | |
| if (!cont) return context; | |
| } else { | |
| cont = context; | |
| } | |
| return $(cont.querySelectorAll(selector)); | |
| } | |
| return $(document.querySelectorAll(selector)); | |
| } | |
| return $(selector, context); | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment