q5play
    Preparing search index...

    Function createSelect

    • 📑 Creates a select element.

      Use the option(label, value) function to add new options to the select element.

      Set multiple to true to allow multiple options to be selected.

      Use the value property to get or set the selected option value.

      Use the selected property get the labels of the selected options or set the selected options by label. Can be a single string or an array of strings.

      Parameters

      • Optionalplaceholder: string

        optional placeholder text that appears before an option is selected

      Returns HTMLSelectElement

      await Canvas(200, 100);

      let sel = createSelect('Select an option');
      sel.option('Red', '#f55');
      sel.option('Green', '#5f5');

      sel.addEventListener('change', () => {
      background(sel.value);
      });