Skip to main content

Bug Tracker

Side navigation

#951 closed bug (fixed)

Opened February 13, 2007 02:53PM UTC

Closed February 23, 2007 04:09AM UTC

Last modified June 20, 2007 01:45AM UTC

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

Reported by: chad@zetaweb.com 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());" /> <= 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>

2. 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.

Attachments (0)
Change History (2)

Changed February 21, 2007 03:47PM UTC by brandon comment:1

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.

Changed February 23, 2007 04:09AM UTC by brandon comment:2

resolution: → fixed
status: newclosed

Fixed in Revision 1406.