我们有一个 asp.NET 页面,它以编程方式将数据添加为无序列表中的新列表项。
我想使用一些 jquery 来显示每个列表项的额外细节的滑动面板,但我使用的代码只显示了系列中的第一个(我猜是因为它们被称为相同的东西).. 怎么做我添加一些条件来选择正确的?
这是代码:
$(文档).ready(函数(){ $(".btn-slide").click(function(){ $(this).slideToggle("slow"); $(this).toggleClass("active"); 返回假; }); }); #控制板 { 背景:#754c24; 高度:200px; 显示:无; } 。滑动 { 边距:0; 填充:0; 边框顶部:实心 4px #422410; 背景:#000 无重复中心顶部; } .btn 幻灯片 { 背景:url(images/white-arrow.gif) 不重复右-50px; 文本对齐:居中; 宽度:144px; 高度:31px; 填充:10px 10px 0 0; 边距:0 自动; 显示:块; 字体:粗体 120%/100% Arial、Helvetica、sans-serif; 颜色:#fff; 文字装饰:无; } 。积极的 { 背景位置:右12px; }
<% foreach( var registration in ViewModel ) { %>
<li>
Event: <%= registration.Event.Name %>
Date: <%= registration.Event.Date.ToLongDateString() %>
<div id="panel">
<% if ( registration.HasResult ) { %>
Your result for this event:
Place: <%= registration.Result.Place %>
Time: <%= registration.Result.Time %>
Average Pace: <%= registration.Result.AveragePace %>
<% } else { %>
No results have been posted for this event.
<% } %>
</div>
<p class="slide"><a href="#" class="btn-slide">Slide Panel</a></p>
</li>
<% } %>
</ul>