0

我想对一个看起来像这样的页面实现一个 jquery get 请求:

<tr class='tr'>
    <td class='example1'>
        <span> Information I have <span>
        <div> Something <div>
    </td>
    <td class='example2'>
        <span> Information I want to get <span>
        <span> something else </span>
    </td>
</tr>

在页面中,有多个“TR”,我想要的是用“我拥有的信息”到达那个并获得“我想要获取的信息”。

我想使用一个ajax请求:

setInterval(function() {
    $.ajax({
        type: "GET",
        url: "url_of_the_page",
        success: test
    });
}, 5000);

function test(html) {
    $(html).find("Information I have").each(function()

但我不知道如何获得信息。

4

1 回答 1

1

您可以使用以下内容:

$(html).find("span:contains('Information I have')").each( function() {
    var text = $(this).text();
    // do stuff with text
});

只有一件事值得一提。上面的选择器区分大小写,因此不会返回带有information而不是的元素。Information

在这里提琴

于 2012-11-17T15:20:35.913 回答