p (child) span (grandchild)
p (child) span (grandchild)
JQuery, head-elementtiin:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("div").find("*").css({"color": "red", "border": "2px solid red"});
});
</script>
CSS-ohjeet:
.ancestors * {
display: block;
border: 2px solid grey;
color: grey;
padding: 5px;
margin: 15px;
}
HTML-koodaukset:
<div class="descendants" style="width:500px;">div (current element)
<p>p (child)
<span>span (grandchild)</span>
<p>
<p>p (child)
<span>span (grandchild)</span>
</p>
</div>