javascript - When element clicked, find closest element relative to this element with another class and toggle it -
i missing here. when row class one
clicked, want find closest row class two
, toggle (show/hide) it.
$(".one").on('click', function() { $(this).find('.two').toggle(); });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <table> <tr class="one"> <td> hello </td> </tr> <tr> <td> world </td> </tr> <tr class="two"> <td> foo </td> </tr> <tr class="two"> <td> bar </td> </tr> </table>
something this:
$(".one").on('click', function() { $(this).nextall('.two:first').toggle(); });
Comments
Post a Comment