HTML
CSS
JavaScript
Vue
React
Python
PHP
Java
.Net
Java9手册
PHP手册
CSS3手册
jQuery手册
源代码
在线运行
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>代码学院(codexy.cn)</title> <style> .descendants *{ display: block; border: 2px solid lightgrey; color: lightgrey; padding: 5px; margin: 15px; } </style> <script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"> </script> <script> $(document).ready(function(){ $("ul").children("li.1").css({"color":"red","border":"2px solid red"}); }); </script> </head> <body class="descendants">body (曾祖先节点) <div style="width:500px;">div (祖先节点) <ul>ul (直接父节点) <li class="1">li (子节点) <span>span (孙节点)</span> </li> <li class="2">li (子节点) <span>span (孙节点)</span> </li> </ul> </div> </body> </html>
动行结果