Remove table rows from a table via script by index?

Can I use script to remove the 2nd and 3rd table row elements from this html?

 <table id="dap_product_links_table"> 
        <tr> 
          <td><span class="scriptheader">Product Title</span></td> 
        </tr> 
        <tr> 
          <td><strong>Access Start Date</strong>: 2010-06-28</td> 
        </tr> 
        <tr> 
          <td><strong>Access End Date</strong>: 2011-06-28</td> 
        </tr>

If so, how?

There are several different ways, but they depend on how you may be later on intending to use the content.

Do you want every table row except for the first one to be removed?
Do you want only the 2nd and 3rd ones being removed?
Do you want only the last two being removed?

Here’s one potential example of the first technique:


var table = document.getElementById('dap_product_links_table'),
    trs = table.getElementsByTagName('tr');
while (trs.length > 1) {
    trs[trs.length - 1].parentNode.removeChild(trs[trs.length - 1]);
}

Hi Paul, thanks for your answer. I just need rows 2 and 3, regardless of how many rows. I can take your code and do the do.

while (trs.length > 1 && trs.length < 3 ) {

Correct?

Right.