首页
极刻
圈子
教程
开源
登录 / 注册
返回教程:jQuery 教程
TRY RUN / 在线示例
jQuery 教程 选取 <p> 元素之后的的所有同级元素
jQuery 教程 选取 <p> 元素之后的的所有同级元素
源代码
运行
<!DOCTYPE html> <html> <head> <script src="//libs.baidu.com/jquery/1.10.2/jquery.min.js"> </script> <script> $(document).ready(function(){ $("p").nextAll().css("background-color","yellow"); }); </script> </head> <body> <p>This is a p element.</p> <div>This is a div element (next sibling of p).</div> <p>This is a p element (next sibling of p).</p> <h4>This is a h4 element (next sibling of p).</h4> <h5>This is a h5 element (next sibling of p).</h5> <p>This is a p element (next sibling of p).</p> <span>This is a span element (next sibling of p).</span> </body> </html>
运行结果