<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>无标题文档</title> <style> .test {color:#fff;margin-left:18px;} </style> </head> <body> <p>如何在文章的每段后面加入一行带连接的隐藏文字?</p> <p>如何在文章的每段后面加入一行带连接的隐藏文字?</p> <p>如何在文章的每段后面加入一行带连接的隐藏文字?</p> <script> function test() { var myP = document.getElementsByTagName("p"); for(var i=0;i<myP.length;i++) { var createLink = document.createElement("a"); createLink.setAttribute("class","test"); createLink.setAttribute("href","http://www.tc711.com/"); createLink.setAttribute("target","new"); var createText = document.createTextNode("网页教学网"); createLink.appendChild(createText); myP[i].appendChild(createLink); } } window.onload = function() {test();} </script> </body> </html>
|