Bug Tracker

Ticket #2817 (new bug)

Opened 5 months ago

Last modified 5 months ago

val() method doesn't work correctly for IE and <button />

Reported by: nberardi Assigned to: anonymous
Type: bug Priority: major
Milestone: 1.2.4 Component: core
Version: 1.2.3 Keywords:
Cc: Needs: Review

Description

The val method seems to return the inner text of a <button /> in IE.

<button id="mybutton" value="1">Change Value</button>

In Firefox the value comes back as 1, however in IE the value comes back as "Change Value".

Attachments

Change History

Changed 5 months ago by nberardi

Probably related to this http://msdn.microsoft.com/en-us/library/ms535211(VS.85).aspx

When the BUTTON element is submitted in a form, the innerText value is submitted.

Changed 5 months ago by flesler

Can't you just use .html() or .text() ? probably one those will work as you expect.

Changed 5 months ago by nberardi

No I don't think you are understanding the problem. The value attribute is ignored in IE, and the text of the button is returned. This is different than all the other browsers which support the standard. I wanted everybody to be aware of this, because jQuery is usually a good buffer between browser incompatibilities.

.html() and .text() both return the innerText of the button element. However I am looking for the value attribute which is usually returned by val(). However in the case of IE the innerText is returned in the val() method.

Note: See TracTickets for help on using tickets.