Modify ↓
Ticket #951 (closed bug: fixed)
$('#foo') conflates id and <a name>
| Reported by: | chad@… | Owned by: | |
|---|---|---|---|
| Priority: | minor | Milestone: | |
| Component: | core | Version: | |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
Description
Steps to Reproduce
- Load the following HTML in IE 6 or 7:
<html>
<head>
<script src="jquery.js"></script>
</head>
<body>
<a name="foo">MUAHAHAHAHA!!!</a>
<p id="foo">Greetings, program!</p>
<input type="button" value="Greetings, program!"
onclick="alert($('#foo').html());" /> <= broken in IE6/7
<hr />
<p name="bar">MUAHAHAHAHA!!!</p>
<p id="bar">Greetings, program!</p>
<input type="button" value="Greetings, program!"
onclick="alert($('#bar').html());" />
<hr />
<a id="baz">Greetings, program!</a>
<p name="baz">MUAHAHAHAHA!!!</p>
<input type="button" value="Greetings, program!"
onclick="alert($('#baz').html());" />
</body>
</html>
- Click on the first button
Expected Result
"Greetings, program!" in the alert box
Actual Result
"MUAHAHAHAHA!!!" in the alert box
Notes
The name attribute only clobbers the id attribute when name is on an anchor tag, as the other two instances on the above page demonstrate.
The bug appears in IE 6 and 7, but not in Firefox 1.5.
This is with jQuery 1.1.1.
Change History
comment:2 Changed 6 years ago by brandon
- Status changed from new to closed
- Resolution set to fixed
Fixed in Revision 1406.
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.
Note: See
TracTickets for help on using
tickets.

There is ongoing discussion about this ticket in this thread on the dev list. I've provided a test page and patch in the thread for further discussion.