Elektrine lite

← Feed

@blinry@chaos.social

Post #2981912

2026-02-15 16:12 UTC

Next, I looked at the Console. I learned that it has some predefined helper functions! You can use `$(selector)` as an abbreviation for `document.querySelector(selector)`. Similarly, `$$(selector)` is short for `document.querySelectorAll(selector)`! Even though this reeks of jQuery, I think these are fantastic in this context and I might use them *a lot*!

Replies (7)

  • @blinry@chaos.social 2026-02-15 16:18

    There are more "Console Helpers" in #firefox: $_ is a shortcut to the result of the last expression you executed, allowing you to do some neat step-by-step exploration. And $0 refers to the currently-inspected element on the page.

    Open ##2981913

  • @adamhotep@infosec.exchange 2026-02-15 16:58

    @blinry@chaos.social what is the difference between $$(…) and $$$(…)? I didn't know about $$(…)

    Open ##2981941

  • @slashme@infosec.exchange 2026-02-15 18:09

    @blinry@chaos.social Small difference: document.querySelectorAll returns a NodeList, not an Array, which means some methods such as map() are missing. $$() returns an Array instead.

    Open ##2981947

  • @groxx@hachyderm.io 2026-02-15 18:14

    @blinry@chaos.social and $0 is the currently selected element - I end up using this more than $(...) selectors by a long shot, unless I need to find multiple elements

    Open ##2981948

  • @lukeharby@infosec.exchange 2026-02-15 19:15

    @blinry@chaos.social I thought modern JS borrowed some of the better parts from jQuery and this sounds like one of them.

    Open ##2981949

  • @diazona@techhub.social 2026-02-15 19:22

    @blinry@chaos.social Huh I think I've used that once or twice but I thought it was due to jQuery having been loaded by the web page. TIL 🙂

    Open ##2981950

  • @elpres@mastodon.social 2026-02-16 07:03

    @blinry@chaos.social There is also $x which takes an XPath selector as its argument

    Open ##2981951