Skip to content

Instantly share code, notes, and snippets.

@jkarnowski
Created April 18, 2016 21:29
Show Gist options
  • Save jkarnowski/62519ccab22ab2d97e1870af3c7f19a3 to your computer and use it in GitHub Desktop.
Save jkarnowski/62519ccab22ab2d97e1870af3c7f19a3 to your computer and use it in GitHub Desktop.
// 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