js 超链接点击
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title></title>
<script>
onload = function () {
var dv = document.getElementById('dv');
for (var i = 0; i < 5; i++) {
var a = document.createElement('a');
a.href = 'javascript:void(0)';
a.innerHTML = 'Link' + i;
a.onclick = function () {
this.style.backgroundColor = 'yellow';
}
dv.appendChild(a);
}
}
</script>
</head>
<body>
<div id="dv">
</div>
</body>
</html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title></title>
<script>
onload = function () {
var dv = document.getElementById('dv');
for (var i = 0; i < 5; i++) {
var a = document.createElement('a');
a.href = 'javascript:void(0)';
a.innerHTML = 'Link' + i;
a.onclick = function () {
this.style.backgroundColor = 'yellow';
}
dv.appendChild(a);
}
}
</script>
</head>
<body>
<div id="dv">
</div>
</body>
</html>