jQuery select specific descendant elements

Description

jQuery select specific descendant elements

View in separate window

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Selecting the Specific Descendant Elements in jQuery</title>
<style>
    *{//from   w  w  w .j  a  va  2 s.  c  om
        margin: 10px;
    }
    .frame{
        border: 2px solid green;
    }
</style>
<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<script>
$(document).ready(function(){
    $("div").find("li").addClass("frame");
});
</script>
</head>
<body>
    <div class="container">
        <h1>Hello World</h1>
        <p>This is a <em>simple paragraph</em>.</p>
        <ul>
            <li>Item One</li>
            <li>Item Two</li>
        </ul>
    </div>
</body>
</html>



PreviousNext

Related