admin管理员组文章数量:1422048
I am able to get td's last child using this
$jq('#stripeTable > tbody > tr:nth-child('+(i+1)+') >td:last-child').text(colValues +" < "+ colValuesWithOverTime);
what to do and get second last child of td like i am getting last child using td:last-child
I am able to get td's last child using this
$jq('#stripeTable > tbody > tr:nth-child('+(i+1)+') >td:last-child').text(colValues +" < "+ colValuesWithOverTime);
what to do and get second last child of td like i am getting last child using td:last-child
Share Improve this question edited May 6, 2017 at 7:54 LF-DevJourney 28.6k30 gold badges165 silver badges316 bronze badges asked May 6, 2017 at 7:17 Muhammad Faizan KhanMuhammad Faizan Khan 10.6k21 gold badges105 silver badges197 bronze badges 3- nth-last-child – Mr Lister Commented May 6, 2017 at 7:25
- stackoverflow./questions/22605785/… – LF-DevJourney Commented May 6, 2017 at 7:39
- 1 Possible duplicate of Select second to last element – Imanuel Commented May 6, 2017 at 7:49
3 Answers
Reset to default 5Try td:nth-last-child(2). This will select the 2nd child from the end.
console.log($("td").last().prev().text());
<script src="https://ajax.googleapis./ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<table>
<tr><td>1</td><td>2</td><td>3</td></tr>
</table>
use last and prev,
$("td").last().prev();
Use .eq()
function to get second last from jQuery array
var count = $('td').length;
var secondLast = $('td').eq(count - 2);
本文标签: javascriptGet second last child td in html tableStack Overflow
版权声明:本文标题:javascript - Get second last child td in html table - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745357057a2655118.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论