ref: dumb it down, full Ai ahead!
This commit is contained in:
parent
607f69e402
commit
dc70e6caab
11
ajquery.js
11
ajquery.js
|
@ -1,7 +1,10 @@
|
||||||
function $(sel, $parent = document) {
|
function $(cssSelector, $parent = document) {
|
||||||
return $parent.querySelector(sel);
|
let $child = $parent.querySelector(cssSelector);
|
||||||
|
return $child;
|
||||||
}
|
}
|
||||||
|
|
||||||
function $$(sel, $parent = document) {
|
function $$(cssSelector, $parent = document) {
|
||||||
return Array.from($parent.querySelectorAll(sel));
|
let nodeList = $parent.querySelectorAll(cssSelector);
|
||||||
|
let $children = Array.from(nodeList);
|
||||||
|
return $children;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
<script src="./ajquery.js"></script>
|
<script src="./ajquery.js"></script>
|
||||||
<script>
|
<script>
|
||||||
document.write("Hello, World!");
|
document.write("Hello, World!");
|
||||||
console.log($("body").textContent));
|
let text = $("body").textContent;
|
||||||
|
console.log(text);
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
|
Loading…
Reference in New Issue