Answer the question
In order to leave comments, you need to log in
This = undefined?
error:
Cannot read properties of undefined (reading 'inf')
import Faw from "./Lizardx";
const {el} = new Faw();
el(".title").styles({
color: "red"
}).on("click", () => {
console.log("click");
});
export default class Lizardx {
constructor(private inf) {
this.inf = {
$el: null
}
}
el(selector) {
this.inf.$el = document.querySelector(selector);
return this.inf;
}
styles(stylesObj) {
for(const primary in stylesObj) {
this.inf.$el.style[primary] = stylesObj[primary];
}
return this.inf;
}
on(event, func) {
this.inf.$el.addEventListener(event, func());
return this.inf;
}
}
Answer the question
In order to leave comments, you need to log in
class TotallyNotAjQuery {
constructor() {
this.inf = {
$el: null
}
this.el = this.el.bind(this);
}
el(selector) {
this.inf.$el = document.querySelector(selector);
return this;
}
styles(stylesObj) {
for(const primary in stylesObj) {
this.inf.$el.style[primary] = stylesObj[primary];
}
return this
}
on(event, func) {
this.inf.$el.addEventListener(event, func);
return this;
}
}
const {el: $} = new TotallyNotAjQuery();
$(".title").styles({
color: "red"
}).on("click", () => {
console.log("click");
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question