当前位置:网站首页>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);边栏推荐
- 从0到100:招生报名小程序开发笔记
- img 响应式图片的实现(含srcset属性、sizes属性的使用方法,设备像素比详解)
- Wechat Gymnasium Reservation Mini Program Graduation Design Finished Work Mini Program Graduation Design Finished Product (2) Mini Program Function
- cmd指令
- Deep learning Course2 first week Practical aspects of Deep Learning exercises
- 程序员如何优雅地解决线上问题?
- PHP算法之最接近的三数之和
- 图论——强连通分量缩点+拓扑排序
- Nacos配置中心之加载配置
- SQL Server (design database--stored procedure--trigger)
猜你喜欢

解决yolov5训练时出现:“AssertionError: train: No labels in VOCData/dataSet_path/train.cache. Can not train ”

小程序毕设作品之微信体育馆预约小程序毕业设计成品(3)后台功能

编曲软件FL studio20.8中文版功能和作用

Postman 批量测试接口详细教程

下载安装 vscode(含汉化、插件的推荐和安装)

(Translation) How the contrasting color of the button guides the user's actions

联邦学习的框架搭建

Use Jenkins for continuous integration, this knowledge point must be mastered

JS prototype hasOwnProperty in Add method Prototype end point Inherit Override parent class method

Small application project works WeChat stadium booking applet graduation design of the finished product (1) the development profile
随机推荐
PAM 回文自动机
PDF转Word有那么难吗?做一个文件转换器,都解决了
SQL Server (design database--stored procedure--trigger)
Nacos配置中心之加载配置
数据增强--学习笔记(图像类,cnn)
如何给 UE4 场景添加游戏角色
计算两点之间的距离
别看了,这就是你的题呀
数据分析04
部门项目源码分享
小程序毕设作品之微信体育馆预约小程序毕业设计成品(1)开发概要
Postman 批量测试接口详细教程
从0到1:图文投票小程序设计与研发笔记
CF1703G Good Key, Bad Key
JS 数组去重(含简单数组去重、对象数组去重)
Use Jenkins for continuous integration, this knowledge point must be mastered
03、GO语言变量定义、函数
毕业作业
Small application project works WeChat stadium booking applet graduation design of the finished product (1) the development profile
解决 win10 下 ISE14.7的 iMPACT 崩溃问题 - FPGA 笔记