我在切换表行类时遇到问题。
我有以下内容:
<tbody>
<tr class="click-row">
<buttton>Show/Hide</button>
</tr>
<tr></tr>
<tr class="hidden-row"></tr>
<tr class="click-row">
<buttton>Show/Hide</button>
</tr>
<tr></tr>
<tr class="hidden-row"></tr>
<tr class="click-row">
<buttton>Show/Hide</button>
</tr>
<tr></tr>
<tr class="hidden-row"></tr>
<tr class="click-row">
<buttton>Show/Hide</button>
</tr>
<tr></tr>
<tr class="hidden-row"></tr>
</tbody>
我想知道,在点击了hidden-row
的行后,如何切换第一个隐藏的行?我使用Angular2。
换句话说:
我想要做的是切换tr下面2行的行,单击该按钮。
答案 0 :(得分:3)
我会利用pygame.key.set_reapeat(50,50)
bProgramLoop = True
while (bProgramLoop == True):
for event in pygame.event.get():
if (event.type == pygame.QUIT):
bProgramLoop = False
if (pygame.key.get_pressed()[pygame.K_LEFT]):
EXECUTE_FUNCTION1()
print "left"
if (pygame.key.get_pressed()[pygame.K_RIGHT]):
EXECUTE_FUNCTION2()
print "right"
来做一个行对象:
ngClass
必须在组件的构造函数中初始化 <tbody>
<tr class="click-row">
<buttton (click)="hiddenRows['0']=true">Show/Hide</button>
</tr>
<tr></tr>
<tr class="hidden-row" ngClass="{'hidden-row': hiddenRows['0']}></tr>
(...)
</tbody>
。
答案 1 :(得分:1)
Jquery解决方案
使用.nextAll()
和:first
$('button').on('click',function(){
$(this).closest('tr').nextAll('.hidden-row:first').toggle();
});
.hidden-row {
display: none;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<table>
<tbody>
<tr class="click-row">
<td>
<button>Show/Hide</button>
</td>
</tr>
<tr></tr>
<tr class="hidden-row">
<td>1st hidden row</td>
</tr>
<tr class="click-row">
<td>
<button>Show/Hide</button>
</td>
</tr>
<tr></tr>
<tr class="hidden-row">
<td>2nd hidden row</td>
</tr>
<tr class="click-row">
<td>
<button>Show/Hide</button>
</td>
</tr>
<tr></tr>
<tr class="hidden-row">
<td>3rd hidden row</td>
</tr>
<tr class="click-row">
<td>
<button>Show/Hide</button>
</td>
</tr>
<tr></tr>
<tr class="hidden-row">
<td>4th hidden row</td>
</tr>
</tbody>
</table>