-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathq.min.js
More file actions
1 lines (1 loc) · 755 Bytes
/
Copy pathq.min.js
File metadata and controls
1 lines (1 loc) · 755 Bytes
1
class QueryJs{#el=null;constructor(e){return e&&("string"==typeof e&&(this.#el=document.querySelector(e)),e instanceof HTMLElement&&(this.#el=e)),this}query(e){return e&&(this.#el=document.querySelector(e)),this}queryAll(e){return e&&(this.#el=Array.from(document.querySelectorAll(e))),this}className(e){return e&&(this.#el=Array.from(document.getElementsByTagName(e))),this}tagName(e){return e&&(this.#el=Array.from(document.getElementsByTagName(e))),this}id(e){return e&&(this.#el=document.getElementById(e)),this}attr(e,t){return"string"!=typeof e||("string"==typeof t?this.queryAll(`[${e}=${t}]`):this.queryAll(`[${e}]`)),this}get(e){return"number"==typeof e&&Array.isArray(this.#el)&&e-1<this.#el.length?this.#el[e-1]:this.#el}}window.Q=new QueryJs;