# 🗿 Surreal ### Tiny jQuery alternative for plain Javascript with inline [Locality of Behavior](https://htmx.org/essays/locality-of-behaviour/)! ![cover](https://user-images.githubusercontent.com/24665/171092805-b41286b2-be4a-4aab-9ee6-d604699cc507.png) (Art by [shahabalizadeh](https://www.deviantart.com/shahabalizadeh)) ## Why does this exist? For devs who love ergonomics! You may appreciate Surreal if: * You want to stay as close as possible to Vanilla JS. * Hate typing `document.querySelector` over.. and over.. * Hate typing `addEventListener` over.. and over.. * Really wish `document.querySelectorAll` had Array functions.. * Really wish `this` would work in any inline ` ``` See the [Live Example](https://gnat.github.io/surreal/example.html)! Then [view source](https://github.com/gnat/surreal/blob/main/example.html). ## 🎁 Install Surreal is only 320 lines. No build step. No dependencies. [📥 Download](https://raw.githubusercontent.com/gnat/surreal/main/surreal.js) into your project, and add `` in your `` Or, 🌐 via CDN: `` ## ⚡ Usage ### 🔍️ DOM Selection * Select **one** element: `me(...)` * Can be any of: * CSS selector: `".button"`, `"#header"`, `"h1"`, `"body > .block"` * Variables: `body`, `e`, `some_element` * Events: `event.currentTarget` will be used. * Surreal selectors: `me()`,`any()` * Choose the start location in the DOM with the 2nd arg. (Default: `document`) * 🔥 `any('button', me('#header')).classAdd('red')` * Add `.red` to any `