![](/img/trans.png)
[英]td:nth-of-type('+element+') not working in casperjs
[英]How to change values for all td:nth-of-type(4)
我正在嘗試更改第4列的值,表示td:nth-of-type(4),新值為“R $ 0”。 我只需要那些已取消狀態的訂單。 最后一列是td:nth-of-type(9),我也有一個帶類的跨度。
這是一張帶有表格的PrtSc https://i.gyazo.com/91a4cc3b38e71ce73a5ebfc809a692d6.png
最后一列td代碼<td><span class="status-cancelled">Cancelled</span></td>
嘗試這個。
$(document).ready(function(){
$rows=$('.table tbody tr');
$rows.each(function(){
status=$(this).children().last().text();
if(status=='Cancelled'){
$(this).children().eq(3).text('R$0');
}
});
});
你真的可以不用jQuery做到這一點?
rows = document.querySelectorAll(".table tbody tr");
Object.keys(rows).forEach(function (key){
if (rows[key].lastElementChild.innerText == "Cancelled") {
rows[key].children[3].innerText = 'R$0';
}
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.