- Practical Web Development
- Paul Wellens
- 132字
- 2021-07-16 13:14:08
Drop-down lists
Often we need to have visitors make a choice from a list. For this purpose, we can use the <select>
element in combination with the <option>
tag for every inpidual choice. The text portion of the <option>
element is what will be displayed, and the value of the value
attribute is what will be passed on for processing. It is very useful to make the first option the one that is not to be chosen, as in the following example:
<select name="colorlist" id="colorlist"> <option value="0">Choose a color</option> <option value="red">Red</option> <option value="blue">Blue</option> <option value="green">Green</option> <option disabled value="orange">Orange</option> </select>
The disabled attribute
Both the <select>
and the <option>
support disabled in case you want to enable an option (or the entire drop-down list) to be displayed but not selectable.
The selected attribute
If you want to preselect one of the choices, use the selected attribute of <option>
.
推薦閱讀
- 多媒體CAI課件設計與制作導論(第二版)
- R語言數據分析從入門到精通
- Redis入門指南(第3版)
- WebAssembly實戰
- Instant Zepto.js
- RTC程序設計:實時音視頻權威指南
- Effective Python Penetration Testing
- 嚴密系統設計:方法、趨勢與挑戰
- JavaScript入門經典
- 區塊鏈技術與應用
- Getting Started with Eclipse Juno
- HTML+CSS+JavaScript編程入門指南(全2冊)
- 深入實踐Kotlin元編程
- scikit-learn Cookbook(Second Edition)
- 從零開始構建深度前饋神經網絡:Python+TensorFlow 2.x