开发者

Is there any way to have multiple ID:s with same name in one HTML document?

开发者 https://www.devze.com 2022-12-19 12:34 出处:网络
I have a form which has severaltags. is this possible: <sele开发者_如何学JAVAct name=\"select1\" id=\"select1\">

I have a form which has several tags.

is this possible:

   <sele开发者_如何学JAVAct name="select1" id="select1">
       <option id="1990" value="1990">1990</option>
       <option id="1991" value="1991">1991</option>
   </select>

   <select name="select2" id="select2">
       <option id="1990" value="1990">1990</option>
       <option id="1991" value="1991">1991</option>
   </select>

The ID are the same...

Thanks


No id can be assigned only once since it is an identity for just a single element. You need to use class instead but i wonder why you need to assign same ids? If you assign same ids to more than one element, and use javascript, etc to manipulate it, then only last element with same id will be taken care of ignoring all previous elements....

For more information, please see:

ID vs CLASS

0

精彩评论

暂无评论...
验证码 换一张
取 消