当前位置:网站首页>添加大量元素时使用 DocumentFragments
添加大量元素时使用 DocumentFragments
2022-08-01 23:03:00 【紫微前端】
`appendChild`
方法向给定元素添加新元素:const li = document.createElement('li');
li.innerHTML = 'List item';
// Append to given list
ul.appendChild(li);
for (let i = 0; i < 100; i++) {
const li = document.createElement('li');
li.innerHTML = `List item ${i}`;
ul.appendChild(li);
}
`DocumentFragment`
在这种情况下使用。我们创建一个没有父级的最小文档,并将我们的元素附加到它上面。它不会触发任何重排或重绘,因为尚未将文档片段添加到页面:const fragment = document.createDocumentFragment();
for (let i = 0; i < 100; i++) {
const li = document.createElement('li');
li.innerHTML = `List item ${i}`;
fragment.appendChild(li);
}
ul.appendChild(fragment);
边栏推荐
- 编曲软件FL studio20.8中文版功能和作用
- NgRx Store createSelector 的单步调试和源代码分析
- Prufer序列
- 选择合适的 DevOps 工具,从理解 DevOps 开始
- Graph Theory - Strongly Connected Component Condensation + Topological Sort
- img 响应式图片的实现(含srcset属性、sizes属性的使用方法,设备像素比详解)
- 数据增强--学习笔记(图像类,cnn)
- SQL29 Calculate the average next day retention rate of users
- excel split text into different rows
- 如何给 UE4 场景添加游戏角色
猜你喜欢
img 响应式图片的实现(含srcset属性、sizes属性的使用方法,设备像素比详解)
分享10套开源免费的高品质源码,免费源码下载平台
xctf攻防世界 Web高手进阶区 webshell
小程序毕设作品之微信体育馆预约小程序毕业设计成品(4)开题报告
When solving yolov5 training: "AssertionError: train: No labels in VOCData/dataSet_path/train.cache. Can not train"
2022年最新河北建筑八大员(机械员)模拟考试题库及答案
Use Jenkins for continuous integration, this knowledge point must be mastered
y84.第四章 Prometheus大厂监控体系及实战 -- prometheus告警机制进阶(十五)
系统可用性:SRE口中的3个9,4个9...到底是个什么东西?
xctf attack and defense world web master advanced area web2
随机推荐
移动端人脸风格化技术的应用
Still struggling with reporting tool selection?To take a look at this
Postman 批量测试接口详细教程
Error creating bean with name ‘dataSource‘:Unsatisfied dependency expressed through field ‘basicPro
A. Doremy‘s IQ-- Codeforces Round #808 (Div. 1)
03. GO language variable definition, function
excel edit a cell without double clicking
excel cell contian two words, seperated by a slash
NgRx Selector 的 Memoization 特性学习笔记
y84.第四章 Prometheus大厂监控体系及实战 -- prometheus告警机制进阶(十五)
CF1703G Good Key, Bad Key
2022年最新河北建筑八大员(机械员)模拟考试题库及答案
C#大型互联网平台管理框架源码:基于ASP.NET MVC+EF6+Bootstrap开发,支持多数据库
APP special test: traffic test
xctf attack and defense world web master advanced area webshell
String - Trie
SQL Server (design database--stored procedure--trigger)
Postman batch test interface detailed tutorial
Interpretation of the paper (GSAT) "Interpretable and Generalizable Graph Learning via Stochastic Attention Mechanism"
将vim与系统剪贴板的交互使用