In this plunker demo,我默认行展开。但我需要它最初崩溃,并且当我展开任何一行时,所有其他行应该崩溃。所有这些功能我只需要使用JQuery ......任何人都可以帮助我吗?...提前感谢
JQuery的
<script>
$(function () {
$('#mytable').on('click', '.toggle', function () {
var findChildren = function (tr) {
var depth = tr.data('depth');
return tr.nextUntil($('tr').filter(function () {
return $(this).data('depth') <= depth;
}));
};
var el = $(this);
var tr = el.closest('tr');
var children = findChildren(tr);
var subnodes = children.filter('.expand');
subnodes.each(function () {
var subnode = $(this);
var subnodeChildren = findChildren(subnode);
children = children.not(subnodeChildren);
});
if (tr.hasClass('expand')) {
tr.removeClass('expand').addClass('collapse');
children.show();
} else {
tr.removeClass('collapse').addClass('expand');
children.hide();
}
return children;
});
});
</script>