Skip to main content

Jquery Find and Highlight Child

· One min read
Kaustubh Kulkarni
index.html
<!DOCTYPE html>
<html>
<head>
<title>find children and highlight</title>
<script src="https://code.jquery.com/jquery-3.4.1.js"></script>
<style>
.highlight{
background: yellow;
}
</style>
</head>
<body>
<div>
<h1>We will trace children of ul element here</h1>
<ul>
<li>I am the eldest</li>
<li>I am the youngest</li>

</ul>
</div>
<script>
$(document).ready(function(){
$("ul").children().addClass("highlight");
});
</script>

</body>
</html>