How To Get Children Element In jQuery

Websolutionstuff | Jul-13-2022 | Categories : jQuery

In this article, we will see how to get the children of this selector in jquery. You can use the find() method to get the children of the $(this) selector using jquery. The find() method returns descendant elements of the selected element. This method traverse downwards along descendants of DOM elements.

So, let's see how to get children of this selector in jquery, how to find the child element in jquery, jquery get the child element by class.

Example: How to Get the Children of the $(this) Selector in jQuery

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery Select the Child Element Inside Div On Click - Websolutionstuff</title>
<style>
    .box{
        padding: 80px;
        border: 6px solid #999;
        text-align: center;
    }  
    .box img{
        width: 400px;
        border: 3px solid #999;
    }
</style>
<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
<script>
$(document).ready(function(){
    $(".box").click(function(){
        $(this).find("img").css("border-color", "red");
    });
});
</script>
</head>
<body>
    <div class="box">
        <img src="images/laravel.jpg" alt="Laravel">
    </div>
</body>
</html>

 


You might also like:

Recommended Post
Featured Post
Carbon Add Days To Date In Laravel 9
Carbon Add Days To Date In Lar...

In this article, we will see carbon add day and add days to date in laravel 9. Carbon provides the addDay() and add...

Read More

Nov-17-2022

Laravel 9 Order By Query Example
Laravel 9 Order By Query Examp...

In this article, we will see laravel 9 order by query example. how to use order by in laravel 9.The orderBy me...

Read More

Mar-28-2022

How To Check Array Is Empty Or Null In Javascript
How To Check Array Is Empty Or...

In this example, I will show you how to check if an array is empty or null in javascript or jquery. When we are wor...

Read More

Aug-18-2020

How to Upgrade from Angular 14 to Angular 15
How to Upgrade from Angular 14...

As a developer, keeping up with the latest advancements in Angular is crucial to stay ahead in the rapidly evolving worl...

Read More

May-31-2023