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

30 lines
617 B
JavaScript

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;
}
}