gpt4 book ai didi

jquery - 如何获取当前选择器之后的元素

转载 作者:行者123 更新时间:2023-12-01 04:59:50 25 4
gpt4 key购买 nike

我的问题可能有点不清楚,所以我举个例子

    <table id="products">
<tr id="P1" class="A1"><td>1x</td><td>Product 1</td><td>&euro; 9,50</td><td><a href="#">(x)</a></td></tr>
<tr id="P2" class="A1"><td>1x</td><td>Product 2</td><td>&euro; 10,50</td><td><a href="#">(x)</a></td></tr>
</table>

我想要完成的是以下功能的工作

    $('#bestelling tr').each(function(index) {
var naam = $(this + " td + td").text();
var id = $(this).attr('id');
alert(id + " " + naam);
});

有谁知道我怎样才能做到这一点?抱歉我对这个问题的简短解释我的英语不太好。

最佳答案

$('#bestelling tr td:eq(1)').each(function(index) {
var naam = $(this).text();
var id = this.id;
alert(id + " " + naam);

// The tr is:
$(this).parent()
// Or the DOM element:
this.parentNode
});

关于jquery - 如何获取当前选择器之后的元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11198715/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com