-1

请参阅下面的 Prepend 行。

$('#Area_Code').keyup(function(){ 
        var searchterm = $(this).val();
        if(searchterm.length > 3) {
            var match = $('tr.data-row:contains("' + searchterm + '")');
            var nomatch = $('tr.data-row:not(:contains("' + searchterm + '"))');
            $('#Sector1_Result').prepend(match)
            match.addClass('selected');
            nomatch.css("display", "none");
        } else {
            $('tr.data-row').css("display", "");
            $('tr.data-row').removeClass('selected');
        }
    });

这从表中获取一行并附加它,我只想要一行中的一个单元格,而不是整行。

4

2 回答 2

1

You can use a combination of .children and .get or .eq. For example if match is the jQuery object containing the row, then you get the nth child whith:

match.children().get(n)
于 2013-07-24T00:01:38.107 回答
0

我会直接在桌子上写 td 选择器

html:

<table id="test">
    <tr>
        <td>joy</td>
        <td>abc</td>
    </tr>
</table>

javascript:

$('td:contains("joy")').css('background-color', 'red');

小提琴:http: //jsfiddle.net/ykZcN/1/

于 2013-07-24T00:19:31.647 回答