How do I get the value that is dropped inside a div and ignore the values that are inside other tags inside the div, using jquery?

0

I have the following HTML:

<tr>
    <td>
        VALOR PARA SER PEGO
        <span>Esse valor não é pra ser pego</span>
        <span>Esse valor também não é pra ser pego</span>
    </td>
</tr>

I have specified what values I would like to get, note that the "VALUE TO BE PEGO" is inside the div however loose inside, is not inside <span> tag, how could I do it to get it?

I tried the following way, but it brings all the values, including those that are within <span> , those that are within <span> I will not use.

$("#tabela > tr > td").text();
    
asked by anonymous 28.02.2018 / 18:55

1 answer

0

Solution:

$("#tabela > tr > td").clone().children().remove().end().text().trim();

This link helped me to solve the problem and has an explanation of the use of each function:

link

    
01.03.2018 / 13:10