Retrieve DOM element from a column

1

I have a Jquery event that captures information from a table row (I am using Jquery DataTables).

var linha = $(this).parents('tr')[0].innerHTML;

The value returned is this:

<td class="text-center sorting_1">118587</td>                                   
<td class="font-w600">113326</td>                                 
<td class="d-none d-sm-table-cell">JOÃO DA SIILVA(<b>68</b>)</td>                                   
<td class="text-center">
    <button id="btnIncluiVisitante" class="btn btn-primary">
        <i class="fa fa-user-plus"></i><label for=""></label>                                       
    </button>
    <button id="btnRemoveVisitante" class="btn btn-primary">                                            
        <i class="fa fa-user-times"></i>
        <label id="qtdeVisitantes">1</label>
    </button>                                     
</td>

How do I get the value 1 that is in the <i> tag with id="qtdeVisitantes" ?

    
asked by anonymous 24.07.2018 / 15:06

1 answer

2

If you want to grab the first object would be:

$(linha).find("#qtdVisitantes").text();

If #qtdVisitants is unique (as it should be) this code is enough:

$("#qtdeVisitantes").text();

Another syntax to get the value directly (I imagine the click of the button btnRemoveVisitant) would be:

$(this).closest("tr").find("#qtdVisitantes").text();

    
24.07.2018 / 15:07