我有一些可扩展的表格行,但我不知道如何做到这一点,以便当一行扩展时,所有其他行都会折叠。
Jquery:
$(document).ready(function() {
$('.expandable').click(function() {
$(this).nextAll('tr').each(function() {
if ($(this).is('.expandable')) {
return false;
}
$(this).toggle(350);
});
});
$('.expandable').nextAll('tr').each(function() {
if (!($(this).is('.expandable'))) $(this).hide();
});
});
HTML:
<table border="0">
<tbody>
<tr class="expandable">
最佳答案
只需折叠具有相同类的所有其他行:
$('.expandable').click(function() {
$(".expandable").slideUp();
$(this).slideDown();
});
关于Jquery 一次展开一行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26510115/