Created
May 28, 2020 13:01
-
-
Save jadudm/14222424f3f90abf85255a6b90c57fcb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title>Replacing JQuery?</title> | |
</head> | |
<body> | |
<script> | |
let MiniQuery = class { | |
constructor (queryString) { | |
this.queryString = queryString; | |
// In JQuery... | |
// $(".thing") selects all instances | |
this.elements = document.querySelectorAll(queryString); | |
console.log(this.elements) | |
} | |
hide () { | |
console.log("hide"); | |
this.elements.forEach(e => { e.style.display = "none" }); | |
return this; | |
} | |
} | |
function $ (selector) { | |
q = new MiniQuery(selector); | |
return q; | |
} | |
</script> | |
<div id="one" class="a">One</div> | |
<div id="two" class="a">Two</div> | |
<div id="three" class="b">Three</div> | |
<div id="four" class="b">Four</div> | |
<div id="five" class="c">Five</div> | |
<script> | |
$(".a").hide(); | |
$("#five").hide(); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment