jquery在jquery v3和v2中包含不同的行为(jquery contains acting different in jquery v3 and v2)

我尝试根据其内容定位表行:

$(function() { $('tr td:contains("SomeString")').css('background-color', 'black'); });

当我使用jquery v3时它工作得很好,但是当我切换到v2时它不起作用。

由于引导要求,我必须使用v2。 另外,它让我感到困惑:它是一个基本功能 - 我的错误在哪里?

I try to target a table row based on its content:

$(function() { $('tr td:contains("SomeString")').css('background-color', 'black'); });

when I use jquery v3 it works perfectly, but when I switch to v2 it does not work.

I have to use v2 due to bootstrap requirements. Also, it puzzles me: it is a basic function - where is my mistake?

最满意答案

我认为最终的答案看起来像这样: http : //pastebin.com/Xf55FcvL

I think the final answer will look something like this: http://pastebin.com/Xf55FcvL

jquery在jquery v3和v2中包含不同的行为(jquery contains acting different in jquery v3 and v2)

我尝试根据其内容定位表行:

$(function() { $('tr td:contains("SomeString")').css('background-color', 'black'); });

当我使用jquery v3时它工作得很好,但是当我切换到v2时它不起作用。

由于引导要求,我必须使用v2。 另外,它让我感到困惑:它是一个基本功能 - 我的错误在哪里?

I try to target a table row based on its content:

$(function() { $('tr td:contains("SomeString")').css('background-color', 'black'); });

when I use jquery v3 it works perfectly, but when I switch to v2 it does not work.

I have to use v2 due to bootstrap requirements. Also, it puzzles me: it is a basic function - where is my mistake?

最满意答案

我认为最终的答案看起来像这样: http : //pastebin.com/Xf55FcvL

I think the final answer will look something like this: http://pastebin.com/Xf55FcvL