我在动态创建的部分中使用手风琴
if (Model != null)
{
int index = 1;
foreach (var offer in Model.GroupBy(tt => tt.Destination))
{
<div class="accordion" id="section<%=index %>"><%= offergroupByProperty.Key%><span></span></div>
<div>... contents.. </div>
index += 1;
}
}
$('.accordion').accordion({ defaultOpen: 'section1' });
风格是 -
.accordion {
margin: 0;
padding: 10px;
height: 20px;
border-top: #f0f0f0 1px solid;
background: #416AA3;
font: tahoma,arial,verdana,sans-serif;
text-decoration: none;
text-transform: uppercase;
color: #FFFFFF;
font-size: 1em;
}
.accordion-open {
background: #dfe8f6;
color: #15428b;
font-weight: bold;
}
.accordion-open span {
display:block;
float:right;
padding:10px;
}
工作正常。但是我想在点击另一部分时停止关闭活动部分。这怎么可能?
答案 0 :(得分:0)
我使用以下代码修复了它 -
$('.accordion').accordion({
defaultOpen: 'section1',
collapsible: true
});
$('.accordion').unbind('click').click(function () {
$(this).next().toggle('fast');
});