<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<script src="jquery-3.6.js"></script>
<title>筛选选择器</title>
</head>
<body>
<div class="father">
<div class="son">我是father的儿子div1</div>
<div class="son">我是father的女儿div3</div>
</div>
<div class="father">
<div class="son">我是father的儿子div2</div>
</div>
<div class="nav">
<p>这是nav的儿子</p>
<div class="b">
<p class="c">这是nav的孙子1</p>
<p class="e">这是nav的孙子2</p>
<p >这是nav的孙子3</p>
<p class="f">这是nav的孙子4</p>
<p >这是nav的孙子34</p>
<p >这是nav的孙子44</p>
<p class="a">这是nav的孙女</p>
</div>
<a href="">儿子</a>
</div>
<script>
$(function () {
/*$('*').css("font-size","30px");*/
//父paarent
$('.son').parent().css("color","red");
$('.son').parent().css("font-size","23px");
console.log($('p').parent());
console.log($('p').parents());
//查找p的父级
//2子
$('.a').parent().css("color","red");
$('.a').parent().css("background-color","yellow");
$('div.b>p').css("color","red");
$('div.b>p').css("font-size","32px");
$('div.b>p.c').css("color","pink");
$('div.b>p.e').css("color","green");
$("div.b>p.c:first").css("background", "red");
$("div.b>p.c:first").css("font-size", "100px");
$("div.b>p.f.first").css("font-size", "100px");
$("div:eq(3)").css("background", "brown");
/* $('.nav').find('div:eq(0)').css("background-color", "pink");*/
console.log($('div'));
console.log($('.nav>div'));
console.log($('.nav>div').children());
/* console.log($('.nav>div').children('div'));
console.log($('.nav>div').children('div').children());*/
$('.nav').children("a").css("font-size","60px");
$('nav>div').children('p').css("color","red");
});
//fond
</script>
</body>
</html>