开发者

using JQuery to convert html tr tags to uppercase for string comparison

开发者 https://www.devze.com 2023-01-10 13:30 出处:网络
I have the following JS function: function tblFilter(colToFilter) { var tableToFilter = $(\"#notesGrid\").find(\"tr\");

I have the following JS function:

function tblFilter(colToFilter) {
var tableToFilter = $("#notesGrid").find("tr");
var columnToFilter = colToFilter;

$.each(columnToFilter, function (i) {
    tableToFilter = tableToFilter.filter(":contains'" + columnToFilter + "')");
});

tableToFilter.show();

};

colToFilter is uppercase and I want to convert what I am comparing to to uppercase as well to ensure case insensitivity.

I have tried this:

function tblFilter(colToFilter) {
    var tableToFilter = $("#notesGrid").find("tr");
    var columnToFilter = colToFilter;

    $.each(columnToFilter, function (i) {
        tableToFilter = tableToFilter[i].innerHTML.toUpperCase().filter(":contains'" + columnToFilter + "')");
 开发者_如何学Go   });

    tableToFilter.show();

};

However it fails saying:

Microsoft JScript runtime error: Object doesn't support this property or method


Try to use match() method of strings.


Can you have a try with the following?

$(tableToFilter[i].innerHTML.toUpperCase()).filter()
0

精彩评论

暂无评论...
验证码 换一张
取 消