Bootstrap实现下拉菜单多级联动

前端之家收集整理的这篇文章主要介绍了Bootstrap实现下拉菜单多级联动前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

本文实例为大家分享了Bootstrap实现下拉菜单多级联动的具体代码,供大家参考,具体内容如下

<Meta charset="UTF-8"> Bootstrap 3 的多级下拉<a href="/tag/caidan/" target="_blank" class="keywords">菜单</a>示例
<input type="hidden" name="category_id" id="category_id" value="" /> <div class="dropdown"&gt; <a id="dLabel" role="button" data-toggle="dropdown" class="btn btn-white" data-target="#" href="javascript:;" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" ><span id="select-title"&gt;选择分类</span> <span class="caret"&gt;</span></a> <ul class="dropdown-menu multi-level" role="menu" aria-labelledby="dropdownMenu"&gt; <li><a href="javascript:;" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" data-index="1" data-title="一级菜单"&gt;一级菜单</a></li> <li class="dropdown-submenu"&gt; <a href="javascript:;" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" data-index="2" data-title="一级菜单"&gt;一级菜单</a> <ul class="dropdown-menu"&gt; <li><a data-index="2-1" href="javascript:;" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" data-title="二级菜单"&gt;二级菜单</a></li> </ul> </li> <li class="dropdown-submenu"&gt; <a tabindex="3" href="javascript:;" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" data-title="一级菜单"&gt;一级菜单</a> <ul class="dropdown-menu"&gt; <li><a tabindex="3-1" href="javascript:;" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" data-title="二级菜单"&gt;二级菜单</a></li> <li class="divider"&gt;</li> <li class="dropdown-submenu"&gt; <a href="javascript:;" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" data-index="3-2" data-title="二级菜单"&gt;二级菜单</a> <ul class="dropdown-menu"&gt; <li><a href="javascript:;" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" data-index="3-2-1" data-title="三级菜单"&gt;三级菜单</a></li> </ul> </li> </ul> </li> </ul> </div>

<script type="text/javascript">

$('.dropdown li a').click(function(){

console.log(this);
title = $(this).attr("data-title");
id = $(this).attr("data-index");
$("#select-title").text(title);
$("#category_id").val(id);
})

如果大家还想深入学习,可以点击进行学习,再为大家附3个精彩的专题:

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持编程之家。

猜你在找的Bootstrap相关文章