jquery uses contains filters to implement exact matching methods _jquery

Source: Internet
Author: User

This article illustrates the way jquery uses contains filters to achieve exact matching. Share to everyone for your reference, specific as follows:

: The contains selector selects the element that contains the specified string.

The string can be text that is directly contained in an element, or is contained in a child element.

Often used with other elements/selectors to select elements in the specified group that contain the specified text, such as:

$ ("P:contains (IS)") indicates that all <p> elements that contain "is" are selected.

Another example:

$ ("P:contains (John)") or $ ("P:contains (" John) ") indicates that all <p> elements that contain" John "are selected.

Variables can also be used in the selector to achieve the purpose of the selection, such as:

$ (document). Ready (function () {
var ddd= "John";
$ ("div:contains (' + ddd + ')"). CSS ("Color", "#f00");


We can also use the jquery filter method and the contains method to achieve a more ambiguous match, such as:

$ (document). Ready (function () {
$ (". Box"). Filter (": Contains (Lee)"). CSS ("Color", "#f00");
});

Indicates that the text color of box containing "Lee" is set to red.

jquery uses contains filters to achieve exact matches:

<! DOCTYPE html>  

More about jquery-related content readers can view the site topics: "jquery drag-and-drop effects and tips summary", "JQuery Extended Skills Summary", "jquery common Classic Effects Summary", "jquery animation and special effects usage Summary" and "jquery Selector usage Summary 》

I hope this article will help you with the jquery program design.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.