ASP.Net,2.0 VS2005,NET 2.0的jQuery 1.8.3,jQuery UI的1.9.2jQuery的可摺疊面板
我有兩個面板(更會以後)我的形式,可以是打開或關閉上在用戶請求。
我正在使用jQuery'.slideToggle'方法。
這是我的標記
<div class="trigger0">Collapsible Header 1 - Click to toggle</div>
<div class="panel0">
content 1
</div>
<div class="trigger1">Collapsible Header 2 - Click to toggle</div>
<div class="panel1">
content 2
</div>
下正常工作
$(document).ready(function() {
$(".trigger0").click(function(){
$(".panel0").slideToggle("medium");
});
$(".trigger1").click(function() {
$('.panel1').slideToggle("medium");
});
});
但這並不
$(document).ready(function() {
for (var vReportSectionCount = 0; vReportSectionCount < 2; vReportSectionCount++)
{
$(".trigger" + vReportSectionCount).click(function(){
$(".panel" + vReportSectionCount).slideToggle("medium");
});
}
});
因爲我不還不知道有多少板最終將設i不想爲每個面板寫一個新行。有人可以向我解釋爲什麼並提出更好的解決方案嗎?
T hank,這是我第一次使用jQuery。很多學習。 – AdamB