国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發(fā) > CSS > 正文

CSS實現在文章每段后面加入帶連接的隱藏文字

2024-07-11 08:21:40
字體:
來源:轉載
供稿:網友

代碼主要理解3個參數:createelement、createtextnode、appendchild。這3個js參數分別是創(chuàng)建元素、創(chuàng)建字符、追加節(jié)點。代碼原理:循環(huán)頁面段落標簽<p>,創(chuàng)建連接元素<a>,創(chuàng)建要顯示的連接字符,用setattribute定義元素a的樣式和連接地址。在循環(huán)標簽<p>后追加創(chuàng)建的元素<a>。

 

<!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://m.survivalescaperooms.com/");
  createlink.setattribute("target","new");
  var createtext = document.createtextnode("網頁設計");
  createlink.appendchild(createtext);
  myp[i].appendchild(createlink);
 }
}
window.onload = function() {test();}
</script>
</body>
</html>

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 自治县| 元阳县| 津市市| 收藏| 永嘉县| 高邑县| 德庆县| 龙江县| 视频| 白沙| 乌苏市| 盱眙县| 梓潼县| 城口县| 谷城县| 东阳市| 拉萨市| 尼木县| 鹤峰县| 舞钢市| 海宁市| 庆云县| 山阴县| 浮山县| 青阳县| 遂溪县| 六盘水市| 玉环县| 古丈县| 福建省| 开化县| 屏南县| 广南县| 宁远县| 恩施市| 莒南县| 西贡区| 沈丘县| 三门县| 无锡市| 谷城县|