| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- export default class Elem {
- constructor(elem){
- this.elem = document.createElement(elem);
- }
- id(v){
- this.elem.id = v;
- return this;
- }
- addClass(v){
- this.elem.classList.add(v);
- return this;
- }
- text(v){
- this.elem.textContent = v;
- return this;
- }
- type(v){
- this.elem.type = v;
- return this;
- }
- placeholder(v){
- this.elem.placeholder = v;
- return this;
- }
- onsubmit(v){
- this.elem.onsubmit = v;
- return this;
- }
- append(v){
- if(v instanceof this.constructor){
- this.elem.appendChild(v.elem);
- }else{
- this.elem.appendChild(v);
- }
- return this;
- }
- appendTo(v){
- if(v instanceof this.constructor){
- v.elem.appendChild(this.elem);
- }else{
- v.appendChild(this.elem);
- }
- return this;
- }
- get(){
- return this.elem;
- }
- }
|