多个Id选择器在不同的作用域? [英] multiple Id selector in different scopes?
问题描述
如何
$(#Genders,$(#tableFor_SEARCH))。buttonset() ;
和
$(#Genders,$(#tableFor_CREATE))。buttonset();
firefox似乎可以,所有浏览器和任何缺点都可以接受吗?
注意:我尝试这种用法,因为jquery与id selector和radio&复选框助手
(特别是标签标签)
您可以在选择器中使用多个id:s没问题。您甚至不需要将其指定为范围:
$(#tableFor_SEARCH #Genders)。buttonset() ;
在页面中出现冲突的id:s将是一个问题。如果同一个ID出现多次,某些浏览器可能会选择忽略其中的任何一个。即使它适用于所有当前浏览器,它仍然违反了标准,它可以停止使用任何浏览器更新。
在选择器中有两个id:s仍然有用,例如,如果您在多个页面上使用相同的脚本,并使用该id来指定页面上的功能。
Id element is unique in whole document, it is ok. How about this
$("#Genders", $("#tableFor_SEARCH")).buttonset();
and
$("#Genders", $("#tableFor_CREATE")).buttonset();
firefox seems ok with this, can this usage acceptable for all browsers and any drawbacks?
Note: I attempt this usage because jquery works with id selector and radio & checkbox helpers (espcially label for tag)
You can use multiple id:s in a selector, that is no problem. You don't even need to specify it as a scope:
$("#tableFor_SEARCH #Genders").buttonset();
Having conflicting id:s in the page will however be a problem. If the same id occurs more than once, some browser might choose to ignore any of them. Even if it works with all current browsers, it's still a violation of the standards and it can stop working with any browser update.
Having two id:s in a selector can still be useful, for example if you are using the same script for several pages, and use the id to specify what functionality is on the page.
这篇关于多个Id选择器在不同的作用域?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!