Find td with specific text, and operate on the td right after that one?

前端 未结 6 659
逝去的感伤
逝去的感伤 2020-12-19 04:13

I\'m not very familiar with jQuery selectors, so would like some help.

I have a table like this:

6条回答
  •  -上瘾入骨i
    2020-12-19 05:01

    This should work...

    $(function() {
        var searchText = "Section Heading 3";
        var output = "";
        $("td").each(function(i, item) {
            if($(item).html() == searchText) {
                output = $(item).html();
                output += $(item).closest("td").html()
            }
        });
    
        console.log(output);
    });
    

    Here's a jsFiddle http://jsfiddle.net/5ELLM/

提交回复
热议问题