Remove certain fields using jQuery

38 views Asked by At

So I have a box widget and a foldable widget tab that has many fields. How can I get rid of the first fields as well as other n-fields, which could be field 4 or 9 or 7th field?

<div class = "widgetPanel containerWidgetPanel foldableBox">
    <div class="boxBody">
        <table class="widgetTable containerWidgetTable">
            <tbody>
               <tr>
                  <td class="boldColumn containerLabel">
                  <td class="fieldColumn containerField">
               </tr>
               <tr>
                  <td class="boldColumn containerLabel">
                  <td class="fieldColumn containerField">
               </tr>
               <tr>
                  <td class="boldColumn containerLabel">
                  <td class="fieldColumn containerField">
               </tr>
               .....
           </tbody>
        </table>
    </div>
</div>

This is what I have so far... Only for the first field...

<script type="text/javascript">
     jQuery(document).ready(function() {
          jQuery( "tr td" ).first().remove();
     });
</script>

Any help would be appreicated! Thanks!

1

There are 1 answers

5
n-dru On BEST ANSWER

Use .eq() - for example to remove 4th td:

jQuery(document).ready(function() {
     jQuery( "tr td" ).eq(3).remove();
});

If you want to remove both tds in first row, use this:

jQuery("tr").eq(1).find("td").remove();