本實例主要是應用optgrounp標記,并設置其label屬性。optgroup標記主要用于對select元素中的選項進行邏輯分組,在optgroup標記中指定的文本是非可選項,一般通過替換文本域可以選項區分開來。
實現分級下拉列表的關鍵代碼如下:
<form id="form1" name="form1" method="post" action=""> <table width="206" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td height="25" background="images/mid_01.jpg"> 圖書分類</td> </tr> <tr> <td height="28" align="center"><select name="book_class" id="book_class"> <optgroup label="Web設計"> <option>網站建設</option> <option>網頁設計</option> <option>JavaScript程序設計</option> </optgroup> <optgroup label="軟件世界"> <option>軟件工程</option> <option>軟件應用</option> </optgroup> </select></td> </tr> </table></form>
聲明:本網頁內容旨在傳播知識,若有侵權等問題請及時與本網聯系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com