Bug Tracker


Ticket #4575 (closed bug: duplicate)

Opened 5 years ago

Last modified 2 years ago

Attribute selector doesn't work in IE7 in the circumstances

Reported by: estahn Owned by:
Priority: major Milestone: 1.4
Component: unfiled Version: 1.3.2
Keywords: Cc:
Blocking: Blocked by:


One of our forms contains an input field with attribute "name" and attribute value "name". Forms that contains such input fields are not accessible via the selector engine.In the example below the form with that kind of input field is called "foo".

	<meta http-equiv="content-type" content="text/html; charset=utf-8" /> 
	<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script> 
<form name="foo">
    <input type="text" name="name" value="form[name=foo]" />
<form name="foo2">
    <input type="text" name="name" value="form[name=foo2]" />

<form name="bar">
    <input type="text" name="name1" value="form[name=bar]" />
<input type="button" id="button" value = "Count" />
<div id="result"></div>
<script type="text/javascript">
    $(function() {
                    'form : ' + $("form").length + "<br />" +
                    'form[name=foo] : ' + $("form[name='foo']").length + "<br />" + 
                    'form[name*=foo] : ' + $("form[name*='foo']").length + "<br />" + 
                    'form[name=bar] : ' + $("form[name='bar']").length + "<br />" +
                    'Workaround for "form[name=foo]" : ' + $("form").filter(function (index) {return $(this).attr('name') == 'foo';}).length 

Results in IE7:

form : 3
form[name=foo] : 0
form[name*=foo] : 0
form[name=bar] : 1
Workaround for "foo" : 1

Results in Firefox 3.0.8:

form : 3
form[name=foo] : 1
form[name*=foo] : 0
form[name=bar] : 1
Workaround for "form[name=foo]" : 1

Change History

comment:1 in reply to: ↑ description Changed 5 years ago by jfrank

I ran into this issue today and have also confirmed that [attribute=value] does not work properly in IE.

With the following markup on the page...

<a href="" disabled="disabled">Test Link</a>

And the following JS...

test = $("a[disabled=disabled]");

IE alerts 0 and all other browsers alert 1.

comment:2 Changed 5 years ago by dmethvin

  • Status changed from new to closed
  • Resolution set to duplicate

Duplicate of #3113 and not unique to jQuery; it's a DOM ambiguity. Avoid form element names such as "name", "length", "method", "action", etc.

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.


Add a comment

Modify Ticket

as closed

E-mail address and user name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.