<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title></title> <script src="jquery-3.2.1.js"></script> <style> .body *{ border: 1px solid green; min-height: 20px; max-width: 300px; margin: 4px; background-color: white; } </style> </head> <body class="body"> <div class="ancestor">祖先 <div>老祖宗 <div name="zhang" >曾祖父 <div>父亲 <div class="oldBrother">大哥</div> <div class="myself"> 我 <div class="firstSon">大儿 <p name="zhang">大孙子</p> <p>二孙子</p> <div>小孙子</div> </div> <div >二儿</div> <p>三儿</p> <div>四儿</div> </div> <div class="div3">三弟</div> <h3>四弟</h3> <p>五弟</p> <p class="p6">六弟</p> </div> </div> </div> </div> </body> <script> //$(".myself").siblings().css("background-color","blue");//所有兄弟 //$(".myself").siblings("div").css("background-color","blue");//是div兄弟 //$(".myself").next().css("background-color","blue");//下一个兄弟 //$(".myself").nextAll().css("background-color","blue");//所有弟弟 $(".myself").nextUntil("p").css("background-color","blue");//.myself和p标签之间的兄弟不包括p
jquery
最新推荐文章于 2022-11-16 10:54:32 发布