[英]Jquery Accordion on unordered list
I need to do something like the below where my UL is collapsible but because the UL is generated from the ASP:Menu control I don't get an ID for the UL so I need to add the accordion to the class somehow. 我需要执行以下类似操作,使我的UL可折叠,但是因为UL是从ASP:Menu控件生成的,所以我没有UL的ID,因此我需要以某种方式将手风琴添加到类中。 Does anyone know how to assign a Jquery effect to a class?
有谁知道如何为一个类分配一个Jquery效果?
<script type="text/javascript">
$(function(){
$('#accordion').accordion();
})
</script>
<ul id="accordion">
<li>
<h3><a href="#">header</a></h3>
<div>
Content goes here
</div>
</li>
<li>
<h3><a href="#">header</a></h3>
<div>
Content goes here
</div>
</li>
</ul>
Generated code: 生成的代码:
<ul class="level1">
<li><a class="level1 staticItem level1">
<img src="/images/calculator.png" alt="" title="" class="icon" />Financial</a></li>
<li><a class="level2 staticItem level2 selected" href="#" onclick="__doPostBack('Menu1','4\\6')">Address</a></li>
<li><a class="level3 staticItem level3" href="/Controls/Financial/AddressBook.aspx" target="_blank">Address Book</a></li>
<li><a class="level3 staticItem level3" href="/Controls/Financial/CustomerTypes.aspx" target="_blank">Customer Types</a></li>
<li><a class="level1 staticItem level1">
<img src="/images/container.png" alt="" title="" class="icon" />Container</a></li>
<li><a class="level1 staticItem level1">
<img src="/images/product.png" alt="" title="" class="icon" />Product</a></li>
</ul>
As I stated in the comment $('.className').accordion();
正如我在评论
$('.className').accordion();
will do the trick. 会成功的
here is an example: 这是一个例子:
HTML HTML
<ul class="myclass">
<li>
<h3><a href="#">header</a></h3>
<div>
Content goes here
</div>
</li>
<li>
<h3><a href="#">header</a></h3>
<div>
Content goes here
</div>
</li>
</ul>
Javascript 使用Javascript
$(function(){
$('.myclass').accordion();
})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.