-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathajquery.mjs
32 lines (27 loc) · 1 KB
/
ajquery.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/** @import('typed-query-selector/strict') */
let AJQuery = { $, $$ };
/**
* AJQuery - The fastest, most lightweight, least dependency jQuery alternative,
* now typed, Ai-enhanced, and better than ever!
* @namespace AJQuery
*/
/**
* Selects the first element that matches the given selector within the specified parent.
* @param {string} sel - The CSS selector to match.
* @param {Document|Element} [$parent=document] - The parent element to search within. Defaults to document.
*/
function $(sel, $parent = document) {
let $child = $parent.querySelector(sel);
return $child;
}
/**
* Select all matching child elements from $parent (which is document by default)
* @param {String} sel - The CSS selector to match.
* @param {Document|Element} [$parent=document] - The parent element to search within. Defaults to document.
*/
function $$(sel, $parent = document) {
let $children = $parent.querySelectorAll(sel);
let children = Array.from($children);
return children;
}
export default AJQuery;