Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

That's pretty much what that include file does, but with "dqs" rather than "$". I'm not a fan of using the $ as it might confuse others that you're using JQuery.


$ is what I would expect and prefer, because it’s what I’ve been using in my browser dev tools for over fifteen years (ah, Firebug; fond reminiscences). If your document doesn’t use the names, you’ll get implementations roughly equivalent to these:

  function $(selector, element = document) {
      return element.querySelector(selector);
  }

  function $$(selector, element = document) {
      return Array.from(element.querySelectorAll(selector));
  }
Reference on more magic available in the console (there’s a lot of good stuff):

https://firefox-source-docs.mozilla.org/devtools-user/web_co... (I think “:help” is my new favourite: opens that URL, which is not particularly discoverable)

https://developer.chrome.com/docs/devtools/console/utilities...


Wouldn't that be a feature? ;-)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: