首頁  >  問答  >  主體

javascript - 如何比较querySelectorAll和getElementById的性能?

我想知道用什么方法去测试?

有人踩,为什么不给个理由。

PHP中文网PHP中文网2748 天前566

全部回覆(1)我來回復

  • 黄舟

    黄舟2017-04-10 12:47:46

    var t=new Date(); for(){querySelectorAll()}500次 var r=new Date(); alert(t-r);

    for(){getElementById()}500次

    回覆
    0
  • 取消回覆