JSFiddle - React, Tailwind, and code Playground

by mazlix

HTML

<div id="parent">
    <table>
        <tr>
            <td>unwanted 1</td>
        </tr>
        <tr>
            <td>wanted!</td>
        </tr>
        <tr>
            <td>unwanted2</td>
        </tr>
        <tr>
            <td>unwanted3</td>
        </tr>
        <tr>
            <td>unwanted 5</td>
        </tr>
    </table>
    <br>
    <table>
        <tr>
            <td>unwanted extra</td>
        </tr>
        <tr>
            <td>unwanted extrawefe</td>
        </tr>
        <tr>
            <td>unwanted extra wer</td>
        </tr>
    </table>
</div>

JavaScript

$("#parent table:first tr").each(function(i){
    var  lng =  $(this).parent().children("tr").length -1;     //(index from 0)
    var olng = $('tr', this).length -1;                        //(index from 0)
    if ((i>0) && (i<(lng-2))) { //we don't want first 1 or last 3
        console.log("("+i +") "+ $(this).children("td").html());
    }
    if (i == (lng-1)){
        console.log("lng: " + lng +"\n"+"olng: "+olng);
    }
});