Bug Tracker

Opened 15 years ago

Closed 15 years ago

Last modified 14 years ago

#951 closed bug (fixed)

$('#foo') conflates id and <a name>

Reported by: [email protected] Owned by:
Priority: minor Milestone:
Component: core Version:
Keywords: Cc:
Blocked by: Blocking:

Description

Steps to Reproduce

  1. 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());" /> &lt;= 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>
  1. 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 (2)

comment:1 Changed 15 years ago by brandon

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.

comment:2 Changed 15 years ago by brandon

Resolution: fixed
Status: newclosed

Fixed in Revision 1406.

Note: See TracTickets for help on using tickets.