javascript - How to hide table rows based on child class name using jquery? -


i have lot of rows , want hide tr doesn't have specific class.

example:

<tr id="game-22590" class="game">     <td class="pos left-edge">         <div>2</div>     </td>     <td class="cost">         <input class="dollars-paid uncorrected" type="text" value="19,99" tabindex="4">     </td> </tr> <tr id="game-22591" class="game">     <td class="pos left-edge">         <div>3</div>     </td>     <td class="cost">         <input class="dollars-paid" type="text" value="23,99" tabindex="4">     </td> </tr> 

the td.cost has input class or two. want hide rows doesn't have uncorrected class.

use .filter() selecting rows has uncorrected class.

$("tr.game").filter(function(){     return $(this).find("input.uncorrected").length == 0; }).hide(); 

$("tr.game").filter(function(){      return $(this).find("input.uncorrected").length == 0;  }).hide();
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>  <table>    <tr id="game-22590" class="game">      <td class="pos left-edge">        <div>2</div>      </td>      <td class="cost">        <input class="dollars-paid uncorrected" type="text" value="19,99" tabindex="4">      </td>    </tr>    <tr id="game-22591" class="game">      <td class="pos left-edge">        <div>3</div>      </td>      <td class="cost">        <input class="dollars-paid" type="text" value="23,99" tabindex="4">      </td>    </tr>  </table>


Comments

Popular posts from this blog

unity3d - Rotate an object to face an opposite direction -

angular - Is it possible to get native element for formControl? -

javascript - Why jQuery Select box change event is now working? -