q5play
    Preparing search index...

    Function createCheckbox

    • 📑 Creates a checkbox element.

      Use the checked property to get or set the checkbox's state.

      The label property is the text label element next to the checkbox.

      Parameters

      • Optionallabel: string

        text label placed next to the checkbox

      • Optionalchecked: boolean

        initial state

      Returns HTMLInputElement

      await Canvas(200, 100);

      let box = createCheckbox('Check me!');
      box.label.style.color = 'lime';

      box.addEventListener('input', () => {
      if (box.checked) background('lime');
      else background('black');
      });