mr-crocs-adventures/tilorswift/js/dialog/elements/Checkbox.js

30 lines
617 B
JavaScript
Raw Permalink Normal View History

2024-12-08 16:53:56 +01:00
export class Checkbox
{
constructor(label, name, isChecked = false)
{
this.name = name;
this.htmlElement = document.createElement('div');
this.onClick = () => {};
this.checkbox = document.createElement('input');
this.checkbox.type = 'checkbox';
this.checkbox.checked = isChecked;
this.checkbox.onclick = () => {
this.onClick();
}
this.htmlLabel = document.createElement('label');
this.htmlLabel.innerText = label;
this.htmlElement.appendChild(this.checkbox);
this.htmlElement.appendChild(this.htmlLabel);
}
isChecked()
{
return this.checkbox.checked;
}
}