querySelector vs. querySelectorAll
问题 I have some trouble in creating a selector in javascript. This is my code: function __(selector){ var self = {}; self.selector = selector; if(typeof selector == 'object'){ self.element = self.selector; }else{ self.element = document.querySelector(self.selector); } // make a .css method to an element self.css = function(propval){ return Object.assign(self.element.style,propval); } return self; } And my html file <script src="js/selector.js"></script> <script> window.onload = function(){ __('p'