> For the complete documentation index, see [llms.txt](https://lochiwei.gitbook.io/web/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://lochiwei.gitbook.io/web/html/element/less-than-select-greater-than.md).

# \<select>

[HTML](/web/html.md) ⟩ [element](/web/html/element.md) ⟩ \<select>&#x20;

{% hint style="info" %}
The <mark style="color:purple;">**`<select>`**</mark> [HTML](https://developer.mozilla.org/en-US/docs/Web/HTML) element represents a control that <mark style="color:yellow;">provides a menu of options</mark>.
{% endhint %}

{% tabs %}
{% tab title="💾 程式" %}
📁 html

```html
<!-- 用 <label> 包裝 <select> 的標籤文字與整個下拉式選單 -->
<label>
    <!-- <select> 標籤文字 -->
    flex-direction:
    <!-- <select> 下拉式選單 -->
    <select id="flexDirection">
        <option value="row">row</option>
        <option value="row-reverse">row-reverse</option>
        <option value="column">column</option>
        <option value="column-reverse">column-reverse</option>
    </select>
</label>
```

📁 js

```javascript
// 1. 先找出 id="flex-direction" 的 <select> 元素
const flexDirectionSelect = document.getElementById('flexDirection');

// 2. 監聽下拉式選單的變更
flexDirectionSelect.addEventListener('change', updateFlexbox);

// 3. 根據下拉式選單的變更，做相對應的反應(更新 flexbox style 屬性)
function updateFlexbox() {
    flexContainer.style.flexDirection = flexDirectionSelect.value;
}
```

{% endtab %}

{% tab title="👥 相關" %}

* 可用 <mark style="color:purple;">**`<select>`**</mark> 來動態選擇 [flex](/web/css/layout/display/flex.md) 的排版方式。
  {% endtab %}

{% tab title="📘 手冊" %}

* [HTML](https://developer.mozilla.org/en-US/docs/Web/HTML) ⟩ [Elements](https://developer.mozilla.org/en-US/docs/Web/HTML/Element) ⟩ [\<select>](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/select)
  {% endtab %}

{% tab title="💈範例" %}

* codepen ⟩ [flexbox (0.0.3) + dropdown lists](https://codepen.io/pegasusroe/pen/JoPWbbp)
  {% endtab %}
  {% endtabs %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://lochiwei.gitbook.io/web/html/element/less-than-select-greater-than.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
