Home  >  Article  >  Web Front-end  >  How to use content filters in jQuery

How to use content filters in jQuery

php中世界最好的语言
php中世界最好的语言Original
2018-04-08 16:48:041463browse

This time I will bring you how to use the content filter in jQuery. What are the precautions when using the content filter in jQuery? Here are practical cases, let’s take a look.

The examples in this article describe the simple usage of content filters in jQuery. Share it with everyone for your reference, the details are as follows:

Introduction

The content filter is based on the text content contained in the DOM element and whether it contains Matching elements are filtered. There are 4 types of content filters: :contains(text), :empty, :has(selector) and :parent, as follows shown in the table.

Filter Description Example
contains(text) Match elements that contain the given text $("li:contains('DOM')") //Match li elements that contain "DOM" text content
:empty Matches all empty elements that do not contain child elements or text $("td:empty") //Match units that do not contain child elements or text Grid
:has(selector) Matches elements containing elements matched by the selector $("td:has(p)") //Match cells containing

tags in the cells of the table

:parent Match elements containing child elements or text $("td: parent") //Match cells that are not empty, that is, the cell also includes sub-elements or text

Second Application

Apply the content filter to match cells that are empty, cells that are not empty, and cells that contain the specified text

Three codes



 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
  
 
 
 
 
 
 
编号祝福对象祝福者字条内容发送时间
1琦琦妈妈愿你健康快乐的成长!2011-07-05 13:06:06
1wgh爸爸愿你健康快乐的成长!2011-07-05 13:06:06
1花花wgh愿你健康快乐的成长!2011-07-05 13:06:06
1科科wgh2011-07-05 13:06:06

Four running results

I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the php Chinese website!

Recommended reading:

How to use VUE to reduce the number of requests to the server

How to use Vue to optimize first screen loading speed

The above is the detailed content of How to use content filters in jQuery. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn