I would like to create a switch event for 2 different TDs in my table row. the event should show / hide the next row of the table.
<table>
<tr>
<td>1</td> <td>2</td> <td>3</td> <td>4</td> <td>5</td> <td class="clickable1">6</td> <td class="clickable2">7</td>
</tr>
<tr>
<td>this row should be toggled between show/hide once one of the clickable TDs were clicked</td>
</tr>
</table>
Here is the code I tried to apply, but it applied each of the classes to the event:
$('.clickable1,.clickable2').toggle(function() {
$(this).parent()
.next('tr')
.show();
}, function() {
$(this).parent()
.next('tr')
.hide();
});
One more thing: I use the psuedo class on every TR CSS hover. How can I distinguish two TRs (for example, the hover effect on two of them)?
Here is what I found to be working so far:
$('.clickable1,.clickable2').click(function() {
$(this).parent()
.next('tr')
.toggle();
});
TR seems to remember this previous state with the toggle command!
source
share