I want to implement something to make myself instead of writing something.querySelector() to write $, I've fixed the half of the problem which is when I want to make document.querySelector()
instead, I can now use $
<div>
<button>hi</button>
</div>
let $ = (x) => {
return document.querySelector(x);
}
div = $("div");
But the thing that I want to do now is to select the button from inside the div, so now I can't do:
div.$("button");
I want to do it, I know a little bit about prototypes, but I don't know how to implement this thing, How?
[EDIT]: I've seen many people saying that It's a bad implementation, could you please tell why?