向复杂的HTML页面添加数据
模仿贴文列表
<html>
<head>
<title>贴文列表</title>
<script src="G:/js/jquery-3.5.1.js"></script>
<script>
$(function(){
var item = $("#parent").html();
$(".load-more").click(function(){
$tr = $(item);
//找到指定标签添加数据
$tr.children().children().children(".avatar").attr("src","https://i2.hdslb.com/bfs/face/a54abe16d28ecc4426e71738ddb5b2d2a8a23a3d.jpg_64x64.jpg");//改变头像
$tr.children().children().children(".nickname").html('#'+Math.floor(Math.random()*0xffffff).toString(16));//改变昵称
$tr.children().children().children(".nickname").css("background-color",'#'+Math.floor(Math.random()*0xffffff).toString(16));//生成随机颜色
$tr.children().children().children(".day").html(Math.floor(Math.random()*30).toString(10)+"天前")//改变时间
var text = ""