我正在使用jQuery,我只是想知道,ID在整个页面中必须始终是唯一的吗?班级,我知道,可以重复多次,你喜欢什么,ID呢?
解决方法
是的,它必须是独一无二的.
HTML4:
http://www.w3.org/TR/html4/struct/global.html
第7.5.2节:
id = name [CS]
This attribute assigns a name to an element. This name must be unique in a document.
HTML5:
http://www.w3.org/TR/html5/dom.html#the-id-attribute
The id attribute specifies its element’s unique identifier (ID). The value must be unique amongst all the IDs in the element’s home subtree and must contain at least one character. The value must not contain any space characters.