这是我切换小计UL行的代码:
$('.parent').live('click',function(){
var sub = $(this).nextUntil('.subtotal').last().next();
sub.slideToggle();
});
'';
for (var parent in cat){
htmlstr += '<ul class="parent">';
htmlstr += '<li>'+cat[parent]['category_name']+'</li>';
htmlstr += '</ul>';
var items = data['categories'][parent]['subs'];
for (var elem in items){
htmlstr += '<ul class="sub">';
htmlstr += '<li class="one">'+items[elem]['category_name']+'</li>';
htmlstr += '<li class="two">'+items[elem]['today']+'</li>';
htmlstr += '<li class="three">'+items[elem]['mtd']+'</li>';
htmlstr += '<li class="four">'+items[elem]['mtd_budget']+'</li>';
htmlstr += '<li class="five">'+items[elem]['lymtd']+'</li>';
htmlstr += '<li class="six">'+items[elem]['ytd']+'</li>';
htmlstr += '<li class="seven">'+items[elem]['lyytd']+'</li>';
htmlstr += '</ul>';
};
// Sub-totals
var items = cat[parent]['sub_total'];
htmlstr += '<ul class="sub subtotal" style="display:none">';
htmlstr += '<li class="one">Sub-Total</li>';
htmlstr += '<li class="two">'+items['today']+'</li>';
htmlstr += '<li class="three">'+items['mtd']+'</li>';
htmlstr += '<li class="four">'+items['mtd_budget']+'</li>';
htmlstr += '<li class="five">'+items['lymtd']+'</li>';
htmlstr += '<li class="six">'+items['ytd']+'</li>';
htmlstr += '<li class="seven">'+items['lyytd']+'</li>';
htmlstr += '</ul>';
};
这适用于Firefox和Chrome,但不适用于IE。但是,如果您出于某种原因安装并打开开发人员工具栏,它将在IE中开始工作。 谢谢你的帮助。