admin管理员组文章数量:1335401
I using drop down list to show menus.however there are some menus having submenus like
-Movies
-In Cinemas now
-Coming Soon
I succeed to write code for simple menus Where i have taken one drop down list and added some items as shown in code.Some items contains sub-item now question is how to add these sub-items in drop down list.
<select id="cd-dropdown" class="cd-select">
<option value="1" >Home</option>
<option value="2" >Movies</option>
<option value="3" >T.V. Shows</option>
<option value="4" >Photos</option>
<option value="4" >Site Help</option>
</select>
but i am unable to add sub-items to the main items.please give any solution
I using drop down list to show menus.however there are some menus having submenus like
-Movies
-In Cinemas now
-Coming Soon
I succeed to write code for simple menus Where i have taken one drop down list and added some items as shown in code.Some items contains sub-item now question is how to add these sub-items in drop down list.
<select id="cd-dropdown" class="cd-select">
<option value="1" >Home</option>
<option value="2" >Movies</option>
<option value="3" >T.V. Shows</option>
<option value="4" >Photos</option>
<option value="4" >Site Help</option>
</select>
but i am unable to add sub-items to the main items.please give any solution
Share Improve this question edited Sep 24, 2015 at 14:56 GreyRoofPigeon 18.1k5 gold badges39 silver badges60 bronze badges asked Sep 24, 2015 at 14:51 DhirajDhiraj 9102 gold badges12 silver badges26 bronze badges 3- Take a look at JQuery-UI. There's a dropdown box that allows sub-items in it. – Johnny Bones Commented Sep 24, 2015 at 14:54
- Why not use the jQuery-UI menu widget? – anmarti Commented Sep 24, 2015 at 14:56
- Or this: callmenick./post/slide-down-menu-with-jquery-and-css – Johnny Bones Commented Sep 24, 2015 at 14:57
2 Answers
Reset to default 5If its in a form you should use optgroup.
<select>
<optgroup label="Swedish Cars">
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
</optgroup>
<optgroup label="German Cars">
<option value="mercedes">Mercedes</option>
<option value="audi">Audi</option>
</optgroup>
</select>
From: http://www.w3schools./tags/tag_optgroup.asp
You can use Bootstrap , for more details you can see the documentation here below the topic
Sub menus on dropdowns:
http://getbootstrap./2.3.2/ponents.html
its just do that
<ul class="dropdown-menu" role="menu" aria-labelledby="dLabel">
...
<li class="dropdown-submenu">
<a tabindex="-1" href="#">More options</a>
<ul class="dropdown-menu">
...
</ul>
</li>
</ul>
本文标签: javascriptHow to add sub item in drop down listStack Overflow
版权声明:本文标题:javascript - How to add sub item in drop down list - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742387943a2465412.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论