javascript - 在 jQuery 中选择 DIV

标签 javascript jquery html css


我有两个 ID 为#container 的div。

第一个 是类.current-content
[div#container -- div.current-content]

第二个包含在 .next-content 类中并包含 current-content
[div#container -- div.next-content -- div#container -- div.current-content]

可能只有一个 #container.current-content 元素来自 second .current-content ?
最终如何做到这一点?
谢谢。 :)

最佳答案

Each id value must be used only once within a document. If more than one element has been assigned the same ID, queries that use that ID will only select the first matched element in the DOM. This behavior should not be relied on, however; a document with more than one element using the same ID is invalid.

来自 http://api.jquery.com/id-selector/

关于javascript - 在 jQuery 中选择 DIV,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21974414/

相关文章:

javascript - 如何在 Angular 中进行其他导入之前从第三部分脚本导入全局变量?

javascript - mouseclick 和 mousemove 事件在 react Canvas 中给出偏移错误

javascript - 按钮仅在双击后切换

java - 试图从当前元素中找到下一个 div 元素

html - 如何将图像放入 100% 高度的表格中?

javascript - ASP.NET OnTextChanged 事件没有立即响应

javascript - 如何检查下拉菜单是否在 Select2 中打开?

jquery - 将delay()与removeClass()一起使用

javascript - Flot 条形图将条形与 X 轴标签对齐

html - 表格单元格上的虚线边框变为实线