Hi,歡迎訪問前端老白
<select> <option value="1">選項1</option> <option value="2">選項2</option> <option value="3">選項3</option> </select>
<select> <option value="1">選項1</option> <option value="2" selected>選項2</option> <option value="3">選項3</option> </select>
<select> <optgroup label="分組1"> <option value="1">選項1</option> <option value="2">選項2</option> </optgroup> <option value="3">選項3</option> </select>
var select = document.createElement("select"); var option1 = document.createElement("option"); option1.value = 1; option1.text = "選項1"; select.appendChild(option1); var option2 = document.createElement("option"); option2.value = 2; option2.text = "選項2"; select.appendChild(option2); var option3 = document.createElement("option"); option3.value = 3; option3.text = "選項3"; select.appendChild(option3); document.body.appendChild(select);
老白網絡 (http://www.lofty888.cn/) 前端 后端 zblog主題.網站地圖xml