UNPKG

jessquery

Version:

Modern JavaScript is pretty good, but typing document.querySelector() is a pain. This is a tiny library that makes DOM manipulation easy. jQuery is around 80kb (30kb gzipped), while this is only around 8kb (3.5kb gzipped). Lots of JSDoc comments so it's s

36 lines (33 loc) 883 B
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>TakeWhile Demo</title> <style> .highlight { background-color: yellow; } </style> </head> <body> <span>1</span> <span>2</span> <span>3</span> <span>4</span> <span>5</span> <span>6</span> <span>7</span> <script type="module"> import { $$, $ } from "../index.js" const elems = $$("span") .if({ is: (el) => parseInt(el.textContent) % 2 === 0, then: (el) => el.css("background-color", "yellow"), or: (el) => el.css("background-color", "pink"), }) .css("border", "2px solid black") .do((el) => console.log(el.textContent)) </script> </body> </html>