Difference between document.getElementById and document.getElementsByClassName

后端 未结 4 1409
闹比i
闹比i 2020-12-09 14:15

In particular why does document.getElementsById work here

add padding
4条回答
  •  甜味超标
    2020-12-09 14:25

    We want to get the unique element and allocate it in a variable this can be done by making use of getElementById. But when we want to get all the products elements and allocate them in a variable then basically we are using getElementByClassName.

提交回复
热议问题