Created
May 25, 2015 16:04
-
-
Save astur/7c08319a414cb456c581 to your computer and use it in GitHub Desktop.
JQuery index in vanilla.js
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
function index(item, collection) { | |
return [].slice.call(document.querySelectorAll(collection)).indexOf(document.querySelector(item)); | |
} | |
console.log(index('#item', '.collection')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment