Skip to main content

Bug Tracker

Side navigation

#6030 closed bug (wontfix)

Opened February 04, 2010 08:20PM UTC

Closed February 05, 2010 04:45PM UTC

JQuery problems with multiple ID Selectors

Reported by: daringdave Owned by:
Priority: major Milestone: 1.4.2
Component: selector Version: 1.4.1
Keywords: Cc:
Blocked by: Blocking:
Description

I'm new ot JQuery, so I'm not sure if this is a bug or intentional. I have 2 parent divs and want to dynamically create a child dialog box inside either without using a Class to identify the HTML elements.

I have the following HTML:

<body>

<div id="ParentID1">ParentID1

<div id="ChildID1">Child1</div>

</div>

<div id="ParentID2">ParentID2

<div id="ChildID1">Child1</div>

</div>

</body>

Notice that the Child Dialog box DIVs have the same ID. Although the Children have the same ID, their Parents DIVs uniquely identify the children DIVs.

JQuery has problem with the following syntax:

$('#ParentID1 #ChildID1')

$('#ParentID2 #ChildID1')

Example:

$('<div>Hello Parent2</div>').insertAfter($('#ParentID2 #ChildID1'));

I have to use the following syntax:

$('#ChildID1', '#ParentID1')

$('#ChildID1', '#ParentID2')

Example:

$('<div>Hello Parent1</div>').insertAfter($('#ChildID1', '#ParentID1'));

Attachments (0)
Change History (1)

Changed February 05, 2010 04:45PM UTC by john comment:1

component: unfilledselector
resolution: → wontfix
status: newclosed

You shouldn't have multiple elements on the page with the same ID (this is invalid HTML). You should probably be using class names instead.