Creates a radio button element.
The parameter is optional. If a string is passed, as in let myRadio = createSelect('food'), then each radio option will have "food" as its name parameter: <input name="food">. If an existing
<span></span> element is passed, as in let myRadio = createSelect(container), it will become the radio button's parent element.Radio buttons extend the p5.Element class with a few helpful methods for managing options:
myRadio.option(value, [label])adds an option to the menu. The first parameter,value, is a string that sets the option's value and label. The second parameter,label, is optional. If provided, it sets the label displayed for thevalue. If an option withvaluealready exists, its label is changed and its value is returned.myRadio.value()returns the currently-selected option's value.myRadio.selected()returns the currently-selected option.myRadio.selected(value)selects the given option and returns it as anHTMLInputElement.myRadio.disable(shouldDisable)Disables the radio button iftrueis passed, and enables it iffalseis passed.
Examples
Syntax
createRadio([containerElement])
createRadio([name])
createRadio()
Parameters
containerElement
Object:
container HTML Element, either a <div></div> or <span></span>.
name
String:
name parameter assigned to each option's <input></input> element.
Returns
p5.Element: new p5.Element object.
This page is generated from the comments in src/dom/dom.js . Please feel free to edit it and submit a pull request!