doc: add types to define args
This commit is contained in:
parent
dc70e6caab
commit
2944bdbc4c
10
ajquery.js
10
ajquery.js
|
@ -1,8 +1,18 @@
|
||||||
|
/**
|
||||||
|
* Select first matching element, just like console $
|
||||||
|
* @param {String} cssSelector
|
||||||
|
* @param {ParentNode} [$parent=document]
|
||||||
|
*/
|
||||||
function $(cssSelector, $parent = document) {
|
function $(cssSelector, $parent = document) {
|
||||||
let $child = $parent.querySelector(cssSelector);
|
let $child = $parent.querySelector(cssSelector);
|
||||||
return $child;
|
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) {
|
function $$(cssSelector, $parent = document) {
|
||||||
let nodeList = $parent.querySelectorAll(cssSelector);
|
let nodeList = $parent.querySelectorAll(cssSelector);
|
||||||
let $children = Array.from(nodeList);
|
let $children = Array.from(nodeList);
|
||||||
|
|
Loading…
Reference in New Issue