Remove child nodes (or elements) or set innerHTML=“”?

后端 未结 3 1143
鱼传尺愫
鱼传尺愫 2021-01-18 21:27

When clearing HTML elements such as select boxes, tables, or lists, is it better/faster to remove the nodes (e.g., select.options.remove(i), table.deleteR

3条回答
  •  囚心锁ツ
    2021-01-18 21:55

    I made a new test that isn't broken.

    http://jsperf.com/innerhtml-vs-removechild/67

    It's not perfect either since part of the sample setup is part of the test so this might skew the results.

    This gives that innerHTML is faster but I don't know by how much.

提交回复
热议问题