这是基于zurb基金会的这个例子:http://foundation.zurb.com/docs/components/dropdown.html
<a href="#" data-dropdown="drop1">Has Dropdown</a>
<ul id="drop1" class="f-dropdown" data-dropdown-content>
<li><a href="#">This is a link</a></li>
<li><a href="#">This is another</a></li>
<li><a href="#">Yet another</a></li>
</ul>
<a href="#" data-dropdown="drop2">Has Content Dropdown</a>
<ul id="drop2" class="f-dropdown content" data-dropdown-content>
<li><a href="#">This is a link</a></li>
<li><a href="#">This is another</a></li>
<li><a href="#">Yet another</a></li>
</ul>
我试过了:
$( ".f-dropdown").attr('data-dropdown-content');
它不起作用。
这可能会阻止子菜单显示吗?
我在身体标签之前也有这个:
<script>
$(document).foundation();
</script>
这是到目前为止的菜单:(除了这个问题外,还插入了所有内容)
<!-- Navigation -->
<ul class="nav menu button-group">
<li class="item-101 current active">
<a href="/social/services/" >Home</a>
</li>
<li class="item-106 deeper parent">
<a class="programs" href="/social/services/index.php/programs-services" >Programs & Services</a>
<ul class="nav-child unstyled small">
<li class="item-107">
<a href="/social/services/index.php/programs-services/child-services-link-example" >Child Services Link Example
</a>
</li>
</ul>
</li>
<li class="item-108">
<a href="/social/services/index.php/featured-articles-news" >Featured Articles & News</a></li>
<li class="item-109">
<a href="/social/services/index.php/resources" >Resources</a></li>
<li class="item-110">
<a href="/social/services/index.php/donate" >Donate</a></li>
<li class="item-111">
<a href="/social/services/index.php/contact-us" >Contact Us</a></li></ul>
<!-- End Navigation -->
如果你想进一步了解这个问题的背景,虽然我认为这不一定与这个问题有关,这是我今天早些时候的问题:How to add data-dropdown="drop1" in a menu
答案 0 :(得分:1)
如果您尝试使用jQuery将data-dropdown-content
属性添加到元素:
$( ".f-dropdown").attr('data-dropdown-content');
是一个 getter 函数。您想要设置属性。试试这个:
$( ".f-dropdown").attr('data-dropdown-content', '');