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 -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -