Skip to content

The selector target the wrong element when an id isn't unique in the DOM #4262

@lseguin42

Description

@lseguin42

Hi,

I report you an issue with any version of jQuery.

<body>
    <div id="homepage">
        <div id="homepage">
            <div class="the-wrong-element-targetted"></div>
        </div>
        <div class="I-want-to-target-this-one"></div>
    </div>
</body>

When I execute jQuery("body>div:eq(0)>div:eq(1)") I should find the element with the class "I-want-to-target-this-one" but the element return have the class "the-wrong-element-targetted"

You can see the bug with the last version of jQuery here:
https://jsfiddle.net/c3q0teyp/7/

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions