ajquery.js/ajquery.mjs

33 lines
1.0 KiB
JavaScript
Raw Permalink Normal View History

2024-08-29 23:29:03 +00:00
/** @import('typed-query-selector/strict') */
let AJQuery = { $, $$ };
/**
* AJQuery - The fastest, most lightweight, least dependency jQuery alternative,
2024-08-30 00:46:25 +00:00
* now typed, Ai-enhanced, and better than ever!
2024-08-29 23:29:03 +00:00
* @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;