doc: add types to define args

This commit is contained in:
AJ ONeal 2024-08-29 16:23:40 -06:00
parent dc70e6caab
commit 2944bdbc4c
No known key found for this signature in database
GPG Key ID: F1D692A76F70CF98
1 changed files with 10 additions and 0 deletions

View File

@ -1,8 +1,18 @@
/**
* Select first matching element, just like console $
* @param {String} cssSelector
* @param {ParentNode} [$parent=document]
*/
function $(cssSelector, $parent = document) {
let $child = $parent.querySelector(cssSelector);
return $child;
}
/**
* Select all matching child elements as a JS Array, just like console $$
* @param {String} cssSelector
* @param {ParentNode} [$parent=document]
*/
function $$(cssSelector, $parent = document) {
let nodeList = $parent.querySelectorAll(cssSelector);
let $children = Array.from(nodeList);