0

我有一个动态表,只显示 10 条记录并使用分页来显示接下来的 10 条记录。我想要一个搜索功能。我遵循本指南http://www.vonloesch.de/node/23但我只能搜索前 10 条记录。

任何帮助表示赞赏。谢谢

4

1 回答 1

0

此功能将根据每一行的内容过滤整个表格的行,而不是您提供的链接中的一个单元格。

// text => the text to search for
// _id => id of table to filter
// noOfHeaderRows => number of header rows :)
function filterTable( text, _id, noOfHeaderRows ) {

    var table = document.getElementById( _id ), contents, row;

    for (var r = noOfHeaderRows; r < table.rows.length; r++){

        row = table.rows[r];
        contents = row.textContent || row.innerText; 
        contents = contents.toUpperCase();
        text = text.toUpperCase();

        if( contents.indexOf( text ) > -1 ) {
            row.style.display = "";
        } else {
            row.style.display = "none";
        }

    }
}

在这里提琴

于 2012-11-16T14:09:55.213 回答