jQuery find() Method Using FreejQuery


 

Understand & Usage

The find() method backward descendant elements of the chosen element

The DOM tree: This method traverses downwards along with descendants of DOM elements, all the way down to the last descendant. To only traverse a single level down the DOM tree (to return direct children), use the children() method.

Tip: To return all of the descendant elements, use the “*” selector It’s very important.

We can use it on a different platform which supports jquery & it’s plugins. The syntax is mentioned below it’s only for a run.

Syntax

$(selector).find(filter)
Code

<html>

<head>
<style>
.descendants * {
display: block;
border: 2px solid grey;
color: lightgrey;
padding: 5px;
margin: 15px;
}
</style>
<script src=”https://ajax.googleapis.com/ajax/libs/
jquery/3.3.1/jquery.min.js”></script>
<script>
$(document).ready(function() {
$(“div”).find(“span”).css({
“color”: “green”,
“border”: “2px solid green”
});
});
</script>
</head>

<body>

<div class=”descendants”
style=”width:500px;”>This is the current element !!!
<p>This is the paragraph element !!!
<span> This is span element !!!</span>
</p>
<p>This is the paragraph element !!!
<span>This is span element !!!</span>
</p>
</div>

</body>

</html>

You can add different titles & tasks for particular area.
Example: If you’re looking for siblings you’ve to add syntax and after then siblings and so on..!

 


———————–

Leave a Reply

Your email address will not be published. Required fields are marked *