Side navigation
#4099 closed bug (wontfix)
Opened February 09, 2009 03:53PM UTC
Closed February 10, 2009 03:30PM UTC
Basic #id selector fails after multiple dynamic html insert
Reported by: | Mongi | Owned by: | john |
---|---|---|---|
Priority: | major | Milestone: | 1.3.2 |
Component: | selector | Version: | 1.3.1 |
Keywords: | #id, selector, dynamic, insert | Cc: | |
Blocked by: | Blocking: |
Description
Hi! I tried to upgrade from 1.2.6 to 1.3.1 and encountered a bug in selectors.
I make a function that inserts div#par with another child div#chi using .after() function. Then i call $("div#par div#chi").length and get normal value of 1.
Afterwards I call the same function and it inserts div#par1 with child div#chi. But now the call $("div#par div#chi").length returns value of 0. Meanwhile $("div#par div[id=chi]") works fine.
This bug appears at least in 1.3.1 version and under all browsers except Chrome 2.0.160.0. In JQuery branch 1.2.x there is no such bug.
Demo of 1.2.6: http://mongi.ru:8080/bug/jq127.html
Demo of 1.3.1: http://mongi.ru:8080/bug/jq131.html
Attachments (1)
Change History (1)
Changed February 10, 2009 03:30PM UTC by comment:1
resolution: | → wontfix |
---|---|
status: | new → closed |
This has to do with the fact that we're using getElementById to find the first matched element on the page - thus we can only find the first element with that ID on the page (and you have multiple elements with the same ID). I recommend generating new, unique, IDs or using [id=NAME].