BN
Size: a a a
BN
AD
BN
class Elem {
constructor(selector) {
this.elem = document.querySelector(selector);
}
html(text) {
this.elem.innerHTML = text;
}
attr(name, value) {
this.elem.setAttribute(name, value);
}
}
let elem = new Elem('#test');
elem.html('!');
elem.attr('title', 'salem');BN
BN
BN
BN
BN
class Rectange {
constructor(width, height) {
this.div = document.createElement('div');
this.div.style.height = height + 'px';
this.div.style.width = width + 'px';
document.body.appendChild(this.div);
}
setWidth(width) {
this.div.style.width = width + 'px';
}
}
let elem = new Rectange(100, 100);
let elem2 = new Rectange(200, 300);
elem.setWidth(1000); Или же тут, почему прописали this везде внутри класса, это как влияет вообще?P
BN
BN
P
BN
BN
P
BN
P
AE
AD
OS