1、
js中通过createElement 创建一个a标签
https://blog.csdn.net/qq_39822451/article/details/102646382
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>菜鸟教程(runoob.com)</title>
</head>
<body>
<p id="demo">单击按钮创建有文本的按钮</p>
<button onclick="myFunction()">点我</button>
<script>
function myFunction(){
for (var i=0;i<5;i++){
var btn=document.createElement("BUTTON");
var t=document.createTextNode("CLICK ME");
btn.appendChild(t);
document.body.appendChild(btn);
var myHref = document.createElement('a');
myHref.id = 'yourId';
myHref.href = 'http://www.baidu.com';
var text = document.createTextNode('百度网站超链接');
myHref.appendChild(text);
document.body.appendChild(myHref);
myHref.onclick = function (){
alert(this.id);
}
}
};
</script>
</body>
</html>