<div id="box"></div>
<input id="changer" type="number" value ='3'>
class Changer {
constructor(t) {
this._init(t);
}
_init(t) {
let el = document.createElement('h3');
let cont = document.querySelector('#box');
el.innerHTML = t;
cont.append(el);
}
}
let val = document.querySelector('#changer').value;
let g = new Changer(val);
- let val = document.querySelector('#changer').value;
+ let val = document.querySelector('#changer');
let el = document.createElement('h3');
let cont = document.querySelector('#box');
t.addEventListener('input', () => {
el.textContent = t.value;
});
el.textContent = t.value;
cont.append(el);