Bug Tracker

Opened 13 years ago

Closed 13 years ago

#6030 closed bug (wontfix)

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:


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'));

Change History (1)

comment:1 Changed 13 years ago by john

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.

Note: See TracTickets for help on using tickets.