27 lines
516 B
TypeScript
27 lines
516 B
TypeScript
export default class Elem {
|
|
private readonly elem: HTMLElement;
|
|
|
|
constructor(tagName) {
|
|
this.elem = document.createElement(tagName);
|
|
}
|
|
|
|
public html(htmlString): Elem {
|
|
this.elem.innerHTML = htmlString;
|
|
return this;
|
|
}
|
|
|
|
public id(id): Elem {
|
|
this.elem.id = id;
|
|
return this;
|
|
}
|
|
|
|
public class(className): Elem {
|
|
this.elem.classList.add(className);
|
|
return this;
|
|
}
|
|
|
|
public el(): HTMLElement {
|
|
return this.elem;
|
|
}
|
|
}
|