如何在另一个div中引用具有与另一个ID相同的ID的元素? [英] How to refer an element having id same as that of another id in another div?

查看:282
本文介绍了如何在另一个div中引用具有与另一个ID相同的ID的元素?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法获得与另一个div中另一个id具有相同id的元素.有人可以帮我吗?

我尝试过的事情:

I cant get the element having same id as that of another id in another div . can any one help me ?

What I have tried:












如果我想命名为id2.我试过像$(''#id2 #name'').但我无法获取.



if i want to name of id2. I tried like $(''#id2 #name''). but i could not get.

推荐答案

(''#id2 #name'').但是我无法获取.
(''#id2 #name''). but i could not get.


在HTML中,禁止多个元素具有相同的id.在其他世界中,id在整个页面上必须是唯一的.因此,如果浏览器遇到非唯一ID,则将其替换为随机唯一ID.他们主要只为后面的元素这样做,但有些人为所有元素做.
这意味着当您搜索一个ID时,您将最多获得一个结果.
尚不清楚为什么要为一个以上的元素提供相同的id,但是如果您要查找分组,请使用name属性-可以是非唯一的...
In HTML it is forbidden that more than one element has the same id. In other worlds id must be unique across the page. So if browsers bump into a non-unique id they will replace it with a random unique id. They do it mostly for the later element only, but some do it for all.
That means that when you search for an id you will get a maximum of one result.
It is not clear why would you give the same id for more then one element, but if you are looking for grouping use name attribute - that can be non-unique...


引用:

如果我想命名为id2.我尝试过

if i want to name of id2. I tried like


这篇关于如何在另一个div中引用具有与另一个ID相同的ID的元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆