Skip to main content

Bug Tracker

Side navigation

#3113 closed bug (duplicate)

Opened July 01, 2008 02:28PM UTC

Closed March 30, 2011 07:30PM UTC

Last modified March 13, 2012 02:51PM UTC

unexpected attr behavior on form with input element named 'action'

Reported by: rryan Owned by: flesler
Priority: low Milestone: 1.3
Component: attributes Version: 1.2.6
Keywords: attr Cc:
Blocked by: Blocking:

Given the following form:

<form action="someaction">

<input type="hidden" name="action" value="somevalue"/>


If you have the dom element for the form, 'f'.

f.action = "foo", sets the value of the input element, not the action attribute on the form.

f.setAttribute("action","foo") sets the action attribute on the form tag.

In jQuery, if you say $("#form").attr("action","foo"), it actually sets the input element named action to 'foo', instead of setting the attribute on the form tag. Is this a bug? 'attr' would seem to imply the functionality of 'setAttribute', not this magic 'action' accessor on the dom element.

Thanks for all your hard work!

Attachments (1)
Change History (13)

Changed July 02, 2008 02:43PM UTC by flesler comment:1

need: ReviewPatch
owner: → flesler
status: newassigned

This was already spotted, we do have a solution in mind.

We'll review this for 1.3.

Changed August 11, 2008 04:41PM UTC by mw44118 comment:2

Slightly related: it seems impossible to select a form by using the action attribute; e.g.,

<form action="x">


$("form[action='x']") will return an empty set of nodes.

Changed February 03, 2009 01:46AM UTC by dmethvin comment:3

Also applies to "method", per #4039.

Changed February 03, 2009 04:00AM UTC by malsup comment:4

This probably applies to any form attribute. I've confirmed action, method, and target. I suspect others will fall into this category as well, such as enctype and accept. Perhaps even coreattrs like title.

Changed March 29, 2009 04:24PM UTC by hakre comment:5

I was able to help myself by using

$("#formid").get(0).setAttribute("action", action);

where action is a variable containing the action value to be set.

Anyway, this is a Bug I would love to see fixed because the jQuery function does not what it is supposed to be. Since jQuery adds a Layer on the standard Javascript Implementation, it should cirumvent the Problem(s) that the Browsers Javascript Implementation has in this case.

Changed February 03, 2010 02:22AM UTC by dmethvin comment:6

Also applies to

per #1169.

Changed June 16, 2010 02:34AM UTC by dmethvin comment:7

component: coreattributes

Changed July 15, 2010 11:49AM UTC by webapp comment:8

I guess this is directly related :

you can't (at least with Firefox 3.6) select a form by any of its attribute, if any field in the form has the name of the attribute.

For an exemple, if a form has an attribute 'autosubmit="yes"' and a input whose name is "autosubmit", $('form[autosubmit=yes]') doesn't select it. $('form[autosubmit]') selects it, though (the value of the input is probably used instead of the value of the attribute).

Changed October 27, 2010 10:54PM UTC by dmethvin comment:9

#7212 is a duplicate of this ticket.

Changed November 18, 2010 08:25PM UTC by Eddie Monge comment:10

Test case for the attr not being set:

Similiar to this but without the input having the name of action:

Only affects FF

Changed March 25, 2011 04:30AM UTC by timmywil comment:11

_comment0: This is fixed with the attrhooks updates.1301027510697117

This is fixed with the attrhooks updates.

Changed March 30, 2011 07:30PM UTC by rwaldron comment:12

priority: minorlow
resolution: → duplicate
status: assignedclosed

Changed March 30, 2011 07:30PM UTC by rwaldron comment:13

Duplicate of #7212.