Selector has
The :has selector selects elements that contain at least one element matching the given selector, not necessarily an immediate descendant. Since :has is not part of the CSS specification, for better performance in modern browsers it is better to use $("your css selector").has(selector/DOM element) instead.
Syntax
This is how we select elements:
$(':has(selector)');
This is how we select elements if we need direct nesting of the selector:
$(':has(>selector)');
Example
Let's select only those paragraphs that have the tag b inside and put the text '!!!' at the end of them:
<p>text</p>
<p>text</p>
<p><b>bold</b> text</p>
<p><b>bold</b> text</p>
$('p:has(b)').append('!!!');
HTML the code will look like this:
<p>text</p>
<p>text</p>
<p><b>bold</b> text!!!</p>
<p><b>bold</b> text!!!</p>