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:
实例代码: