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();  }); 

http://jsfiddle.net/derekl/5ossufmj/


Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

excel vba - VBA Proxy auto-configuration for http requests -

php - phpWord - Tables with borders in headers/footers -