Created
April 18, 2016 21:29
-
-
Save jkarnowski/62519ccab22ab2d97e1870af3c7f19a3 to your computer and use it in GitHub Desktop.
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
// my module is SweetSelector | |
// What is public and available from outside the module?? What will be private and not available from outside? | |
// What's the context of <blah> relative to the Window? | |
// this is one approach to setting up a module and returning an object with the data that you want | |
var SweetSelector = (function(){ | |
this.select = function(htmlElement){ | |
console.log(htmlElement) | |
if (htmlElement.includes('#')) { | |
return document.getElementById(htmlElement.substring(1)) | |
} | |
else if (htmlElement.includes('.')) { | |
return document.getElementsByClassName(htmlElement.substring(1)); | |
} | |
else { | |
return ("can't find that element") | |
} | |
} | |
return { | |
select: select | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment