lundi 10 octobre 2016

Find an element with unchecked checkbox and remove its ancestor

My HTML

<div class="apartment-entry-container">
  <table>
    <tr>
     <td>
        Description
        <input type="checkbox">
     </td>
    </tr>
  </table>
</div>
<div class="apartment-entry-container">
  <table>
    <tr>
     <td>
        Description
        <input type="checkbox">
     </td>
    </tr>
  </table>
</div>

<div><span class="hidenone">Click Here To Hide</div>

MY jQuery

 jQuery('.hidenone').click(function(){
           jQuery('.apartment-entry-container  input:not(:checked)').each(function() {
                  jQuery(this).parent('.apartment-entry-container').remove();
                });
            }); 

Good evening. I have a list of entities on a page where the user will select the entites they want to include in the coming function. They will include these entites by clicking the checkbox in each .apartment-entry-container.

What I need to do before however is remove all the entites that do not have a checked checkbox. My code is removing all of the entities checked or not.




Aucun commentaire:

Enregistrer un commentaire