Open In App
Related Articles

jQuery has() Method

Improve Article
Save Article
Like Article

The has() is an inbuilt method in jQuery which is used to find all the elements inside the specified list of elements. 



Parameter: It accepts a parameter expression or an element to match elements against them. 

Return Value: It returns all elements that match the specified selector having one or more elements inside them. 

jQuery code to show the working of has() method: 

Example 1:  


<!DOCTYPE html>
    <script src=
    <!-- jQuery code to show the working of this method -->
        $(document).ready(function () {
                "background-color", "lightgreen", "bold");
        body {
            width: 50%;
            height: 100px;
            border: 2px solid green;
            padding: 15px;
            font-size: 19px;
        Geeks !
        I am a
        This is a normal paragraph .

All the “p” elements containing the “span” elements get highlighted. 

Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Last Updated : 07 Jul, 2023
Like Article
Save Article
Similar Reads
Complete Tutorials