2017-04-10 85 views
1

我怎样才能选择210.00与选择器?选择器jquery后

<tr class="order-total"> 
    <th>Total</th> 
    <td data-title="Total"> 
    <strong> 
     <span class="woocommerce-Price-amount amount"> 
     <span class="woocommerce-Price-currencySymbol">$</span> 
     210.00 
     </span> 
    </strong> 
    </td> 
</tr> 
+0

我觉得你应该把这个值210.00中的一个元素(跨度例子。然后,选择它会容易得多:) – Barudar

+0

'$('。woocommerce-Price-amount.amount:contains(210.00)')'......是吗? – Jai

+0

例如,你需要在''中放置'210.00',在得到'span'元素后,你可以使用'.text()' – simon

回答

0

只是一味

var allChildNodes = $("td[data-title='Total'] span").first()[0].childNodes; 
var lastSpanNode = allChildNodes[ allChildNodes.length - 1 ]; 

var allChildNodes = $("td[data-title='Total']").find("span").first()[0].childNodes; 
var lastSpanNode = allChildNodes[ allChildNodes.length - 1 ]; 

得到其数值做

lastSpanNode.nodeValue 
+0

它返回[文本对象] –

+0

@YaSsineTagmatRakini你需要通过执行'lastSpanNode.nodeValue'获得价值 – gurvinder372

+0

感谢您的帮助。你能帮我吗你能告诉我怎样才能更新它的文本(210.00) –

0

试试这个

var myNumber = $('.woocommerce-Price-amount').html().replace("<span class=\"woocommerce-Price-currencySymbol\">$</span>", ""); 
alert(myNumber.trim()); 
0

另一个小办法,找出210.00

var total = $('tr.order-total td[data-title="Total"]').text().replace('$', '').trim(); 
console.log(total); 

回环地址:https://jsfiddle.net/mb7s24pb/