Capture text inside a td via jQuery

0

How do I get hold of the value (R $ 11.20)?

<td class="monetary" databind = "text: value label, visible: $parent.isShippingKnown()">R$11,20 </td>

It did not work, and it has this other structure, I need only the text: "$ 8.62 - Up to 8 business days"

<span data-bind="text: maxEstimateOptionText">Econômica - R$ 8,62 - Até 8 dias úteis</span>


$('#Econômica').text(); // Retorna
$('#Convencional).text(); // Retorna
$('#Rápida).text(); //Retorna
$('#Entrega Agendada I Convencional').text(); // Não Retorna
$('#Entrega Agendada I Sábado').text(); // Não retorna


<li data-bind="attr: {'class': idAttr}, css: { selected: name == $parent.selectedSlaName() }" class="seller-BTP-sla-EntregaAgendadaISabado">
    <a href="javascript:void(0)" data-bind="click: function() { $parent.selectedSlaName(name) }, attr: { 'id': name }" id="Entrega Agendada I Sábado">
        <i class="icon-ok" data-bind="visible: name == $parent.selectedSlaName()" style="display: none;"></i> &nbsp;
        <span data-bind="text: maxEstimateOptionText">Entrega Agendada I Sábado - A partir de R$ 76,20 - Primeira data em 06/08/2016</span>
    </a>
</li>

<a href="javascript:void(0)" data-bind="click: function() { $parent.selectedSlaName(name) }, attr: { 'id': name }" id="Entrega Agendada I Sábado">
    <i class="icon-ok" data-bind="visible: name == $parent.selectedSlaName()" style="display: none;"></i> &nbsp;
    <span data-bind="text: maxEstimateOptionText">Entrega Agendada I Sábado - A partir de R$ 76,20 - Primeira data em 06/08/2016</span>
</a>
<i class="icon-ok" data-bind="visible: name == $parent.selectedSlaName()" style="display: none;"></i> &nbsp;
<span data-bind="text: maxEstimateOptionText">Entrega Agendada I Sábado - A partir de R$ 76,20 - Primeira data em 06/08/2016</span>
    
asked by anonymous 26.07.2016 / 02:46

3 answers

0

Here's an example of how to extract text from an HTML element and manipulate it. In this example I took the text from the DIV and placed it inside an Input.

I hope I have helped.

$(function(){
    var valorDaDiv = $(".divdemonstracao").text();    
    $("#inputdemonstracao").val(valorDaDiv);
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script><divclass="divdemonstracao">Produto teste 1</div>

<br><br>

Texto vai aparecer dentro do Input:<br>
<input type="text" id="inputdemonstracao">
    
26.07.2016 / 03:08
0

I do not know what the rest of the HTML structure looks like, but a code like this resolves to the case presented:

$("td.monetary").text();

By structure it looks like you're using knockoutjs, if there are any other options.

    
26.07.2016 / 02:54
0
  

I need only the text: "$ 8.62 - Up to 8 business days"

$(document).ready(function(){
  var span = $("span").text();    
  var dados = span.split("Econômica - ");
  console.log(dados[1]);
  alert(dados[1]);
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><spandata-bind="text: maxEstimateOptionText">Econômica - R$ 8,62 - Até 8 dias úteis</span>
    
21.08.2017 / 10:10