connectedCallback() {
const template = `
<button class="countdown-start">Start the countdown</button>
<span class="seconds-left"></span>`;
this.innerHTML = template;
this.button = this.querySelector('.countdown-start');
this.secondsDisplay = this.querySelector('.seconds-left');
this.button.addEventListener('click', () => this.handleClick());
}
can be written
- without HTML
- without classes
- without querySelector
- without addEventListener
connectedCallback() {
const createElement=(t,p={})=>Object.assign(document.createElement(t),p);
this.append(
this.button = createElement("button", {
textContent: "Start the Countdown",
onclick: () => this.handleClick()
}),
this.secondsDisplay = createElement("span")
);
}
Top comments (0)