Home >Web Front-end >JS Tutorial >Usage examples of has() method in jQuery_jquery
The example in this article describes the usage of the has() method in jQuery. Share it with everyone for your reference. The specific analysis is as follows:
This method retains matching elements that contain a specific descendant.
The .has() method will recreate a set of matching objects from the original jQuery object.
The method will traverse the descendants of the original object by deleting the selected parameters, and objects containing matching descendants will be retained.
Grammar structure 1:
Parameter list:
Example code:
Matches li elements containing span elements and sets the font color inside them to green.
Grammar structure 2:
Parameter list:
实例代码:
匹配含에는 匹将其中字体颜color设置为绿color가 있습니다.
希望本文所述对大家의 jQuery는 매우 유용합니다.