Ticket #7712 (closed bug: duplicate)
.attr / child element mixup
| Reported by: | daniel@… | Owned by: | daniel@… |
|---|---|---|---|
| Priority: | high | Milestone: | 1.6 |
| Component: | manipulation | Version: | 1.4.4 |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
Description (last modified by jitter) (diff)
$('#myform').attr('action', 'http://google.com') fails if the form has a hidden element named action. Example markup:
<form action="http://bing.com" method="post" id="myform">
<input type="hidden" name="action" value="something" />
</form>
I'll post a testcase as soon as I have time.
Change History
comment:3 follow-up: ↓ 4 Changed 2 years ago by rwaldron
- Owner set to daniel@…
- Status changed from new to pending
Is it broken in a specific browser? This works for me:
comment:4 in reply to: ↑ 3 Changed 2 years ago by jitter
Replying to rwaldron:
Is it broken in a specific browser? This works for me: http://jsfiddle.net/rwaldron/mVaPj/1/
broken e.g. in FF 3.6.12, IE6 (throws exception)
But this is something that should get fixed with the .attr() rewrite for 1.5
comment:5 Changed 2 years ago by jitter
- Status changed from pending to closed
- Resolution set to duplicate
This is a well known problem (References)
Deadly Expandos
Unsafe Names for HTML Form Controls
The problem comes from the old DOM 0/DOM 1 days. DOM 1 HTML states
The FORM element encompasses behavior similar to a collection and an element. It provides direct access to the contained input elements as well as the attributes of the form element.
As noted in my comment above this should all go away with the upcoming .attr() rewrite.
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

Improved markup: http://jsfiddle.net/mVaPj/