Reference createCheckbox()

createCheckbox()

Creates a checkbox <input> element.

Checkboxes extend the p5.Element class with a checked() method. Calling myBox.checked() returns true if it the box is checked and false if not.

The first parameter, label, is optional. It's a string that sets the label to display next to the checkbox.

The second parameter, value, is also optional. It's a boolean that sets the checkbox's value.

Examples

Syntax

createCheckbox([label], [value])

Parameters

label

label displayed after the checkbox.

value

value of the checkbox. Checked is true and unchecked is false.

Notice any errors or typos? Please let us know. Please feel free to edit src/dom/dom.js and open a pull request!

Related References