What is the implementation of GetElementByID()?

前端 未结 3 1277
故里飘歌
故里飘歌 2021-01-21 08:00

Can somebody please explain to me the internal implementation of HTML getElementById() method ? Is it traversing whole DOM tree to find the specified element or is it intelligen

3条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-21 08:24

    That depends. The method is implemented by each web browser vendor, so the details may be different from one to another and possibly from one version of a browser to another.

    I'd suggest taking a look at the source code for a browser such as Mozilla Firefox and see if you can find the implementation.

提交回复
热议问题