Contains selector css Note: The text is case sensitive. The attribute selector is just like any other selector (it can be used as a "stand alone"). But I found out that if you had many cases to test, jQuery will perform very badly (especially on IE6, I know, it's old but still in use). This is mostly used together with another selector to select the elements containing the text in a group. Case Sensitivity The :contains() selector is h1:contains("CSS"), h2:contains("CSS") { color: red; } 上面的CSS代码将把所有包含“CSS”文本的标题元素的文本颜色设置为红色。 注意事项. There's also ^= for the beginning of a string, and $= for the end of a string. Containment enables isolating a subsection of the DOM, providing performance benefits by limiting calculations of layout, style, paint, size, or any combination to a DOM subtree rather than the entire page. You can try use a jQuery selector :contains(), add a class and then do a normal style for a class. Mar 10, 2025 · The contain CSS property indicates that an element and its contents are, as much as possible, independent from the rest of the document tree. The correct syntax would be $("li:contains('John'),li:contains('Mary')"). dtyvrcxjzucqbhothupxoijwwfzkspqlgxsduzmtqsjtmnjrfkgsbfkwlyuwamrdzbupxipeh