What practical problem will i face if i use same #id more than one time on a page , other than validation error “ID is already defined”?

前端 未结 7 756
甜味超标
甜味超标 2021-01-13 15:09

First of all I alwyas use one #ID. just asking this question to know deep reason behind it.

Is it only a matter of W3C validation? or more than that

7条回答
  •  南笙
    南笙 (楼主)
    2021-01-13 15:40

    I've had experiences where certain JavaScript code didn't work as expected because two elements had the same ID. I think getElementById just gets the first element it comes to that has the particular ID.

提交回复
热议问题