-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
27 lines (23 loc) · 757 Bytes
/
Copy pathindex.html
File metadata and controls
27 lines (23 loc) · 757 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<html>
<head>
<script src="G:/js/jquery-3.5.1.js"></script>
<script>
$(function(){
var html = $("#div0").html();
$("#btn").click(function(){
$tr = $(html);
$tr.attr("href","https://www.baidu.com");//改变链接内容
$tr.html('#'+Math.floor(Math.random()*0xffffff).toString(16));//改变链接文字
$tr.css("background-color",'#'+Math.floor(Math.random()*0xffffff).toString(16));//生成随机颜色
$("#div0").append($tr);
})
});
</script>
</head>
<body>
<div id = "div0">
<a id="link" href="https://www.runoob.com/js/js-htmldom.html">哈哈哈</a><br>
</div>
<input id="btn" type="button" value="点击">
</body>
</html>