Edit The Code:
See Result »
Try it Yourself - ©
w3big.com
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>本教程(w3big.com)</title> <script src="http://cdn.static.w3big.com/libs/jquery/1.10.2/jquery.min.js"> </script> <script> $(document).ready(function(){ var treeTraversal = $("div").find("p,span").map(function(){ return this.tagName;}).get().join(", "); $("div").after("<h2>" + treeTraversal + "<h2>"); }); </script> </head> <body> <div>这是一个div元素,我的子节点是: <p> <span><span></span></span> </p> </div> </body> 在这个例子中,将返回div的所有后代元素。 </html>