搜索文档
首页
HTML/CSS
JavaScript
服务端开发
Java教程
移动端
数据库
当前位置:
首页
JavaScript
jQuery 教程
jQuery 遍历
源代码
清空
点击运行
<!DOCTYPE html> <html> <title>jQuery children()遍历后代示例 - 基础教程(div.cn)</title> <head> <script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script> <script> $(document).ready(function(){ $("div").children("p").css("background-color", "coral"); }); </script> </head> <body> <p>这是body内的p元素。</p> <div style="border:1px solid;"> <p> DIV中的第一段。</p> <h4>这是DIV中的标题4元素。</h4> <p> DIV中的第二段。</p> <span>这是DIV中的span元素。</span> <p> DIV中的最后一段。</p> </div> <p>这是body内的p元素。</p> </body> </html>
运行结果