#11146 closed bug (invalid)
Exclamation in id selector does not match the matching element
Reported by: | aishwar.muthuraman | Owned by: | |
---|---|---|---|
Priority: | low | Milestone: | None |
Component: | selector | Version: | 1.7.1 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
When an element's id contains an exclamation mark, the jQuery id selector does not match it, while document.getElementById matches it.
See http://jsfiddle.net/MKP43/1/ for example.
e.g. $('#abc!1') will always match nothing.
Change History (5)
comment:1 Changed 11 years ago by
comment:2 follow-up: 3 Changed 11 years ago by
Component: | unfiled → selector |
---|---|
Priority: | undecided → low |
Resolution: | → invalid |
Status: | new → closed |
The exclamation point must be escaped.
comment:3 Changed 11 years ago by
Replying to timmywil:
The exclamation point must be escaped.
I have the same issue! Im trying to use jquery to select a tag with <a href="#">!--</a> inside, and this is not working out.
For example if (a == "!--"){}
comment:4 Changed 11 years ago by
I have the same issue! Im trying to use jquery to select a tag with <a href="#">!--</a> inside, and this is not working out.
For example if (a == "!--"){}
I did debug this and this will fix it:
Changing
to
The above expression satisfies the HTML5 spec for ids: http://dev.w3.org/html5/spec/Overview.html#the-id-attribute
Ids should contain atleast one character and should not contain spaces.