当前位置:网站首页>When using DocumentFragments add a large number of elements
When using DocumentFragments add a large number of elements
2022-08-01 23:07:00 【Ziwei front end】
`appendChild`
method to Add new element:const li = document.createElement('li');li.innerHTML = 'List item';// Append to given listul.appendChild(li);
for (let i = 0; i < 100; i++) {const li = document.createElement('li');li.innerHTML = `List item ${i}`;ul.appendChild(li);}
`DocumentFragment`
in this case.We create a minimal document with no parent and attach our element to it.It doesn't trigger any reflow or repaint because the document fragment hasn't been added to the page yet: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);
边栏推荐
- 【Verilog刷题篇】硬件工程师从0到入门1|基础语法入门
- 图论——强连通分量缩点+拓扑排序
- JS prototype hasOwnProperty in 加方法 原型终点 继承 重写父类方法
- vscode hide menu bar
- PHP算法之最接近的三数之和
- excel edit a cell without double clicking
- 别看了,这就是你的题呀
- Error creating bean with name ‘dataSource‘:Unsatisfied dependency expressed through field ‘basicPro
- 文件查询匹配神器 【glob.js】 实用教程
- PAM 回文自动机
猜你喜欢
随机推荐
关于ETL的两种架构(ETL架构和ELT架构)
从0到1:图文投票小程序设计与研发笔记
perspectiveTransform warpPerspective getPerspectiveTransform findHomography
2022年最新河北建筑八大员(机械员)模拟考试题库及答案
03. GO language variable definition, function
基于 OData 模型和 JSON 模型的 SAP UI5 表格控件行项目的添加和删除实现
深度学习Course2第一周Practical aspects of Deep Learning习题整理
添加大量元素时使用 DocumentFragments
用virtualenv和Virtualenvwrapper虚拟环境管理工具创建虚拟环境
数据分析04
PAM 回文自动机
解决yolov5训练时出现:“AssertionError: train: No labels in VOCData/dataSet_path/train.cache. Can not train ”
牛客多校4 A.Task Computing 思维
文件查询匹配神器 【glob.js】 实用教程
From 0 to 1: Design and R&D Notes of Graphic Voting Mini Program
Deep Learning Course2 Week 2 Optimization Algorithms Exercises
xctf attack and defense world web master advanced area webshell
[Recommended books] The first self-driving technology book
最短路模板
论文解读(GSAT)《Interpretable and Generalizable Graph Learning via Stochastic Attention Mechanism》