fmpq.com
源代码:
点击运行
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Fmpq教程(fmpq.com)</title> <script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"> </script> <script> $(document).ready(function(){ var treeTraversal = $("span").parents().map(function(){ return this.tagName;}).get().join(", "); $("span").after("<h2>" + treeTraversal + "<h2>"); }); </script> </head> <body> <div> <p> <span>这是一个span元素,我的祖先元素是: </span> </p> </div> </body> </html>
运行结果