CSS在文章每段后添加带链接的隐藏文字
完整的代码如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<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","");
createLink.setAttribute("target","new");
var createText = document.createTextNode("中国站长天空");
createLink.appendChild(createText);
myP[i].appendChild(createLink);
}
}
window.onload = function() {test();}
</script>
</body>
</html>