jQuery: The Write Less, Do More JavaScript Library

Ticket #2099 (closed bug: fixed)

Opened 8 months ago

Last modified 3 months ago

IE: $('#someform').attr('id') returns sub element instead of attribute

Reported by: streawkceur Assigned to: anonymous
Type: bug Priority: major
Milestone: 1.2.2 Component: core
Version: 1.2.1 Keywords: attr ie form
Cc: Needs: Review

Description

HTML:

<form id="someform" name="someform">
    <input name="id" value="23" />
</form>

JS:

$('#someform').attr('id')

Gives '[object]' in IE. This is actually the input element. In FF the correct value 'someform' is alerted.

"Fix":

if (jQuery.browser.msie) {
    alert( $('#someform').attr('attributes')['id'].value );
} else {
    alert( $('#someform').attr('id') );
}

This error may occur on several other attributes. Also, it works when there is no sub-element with the name 'id'.

Attachments

Change History

Changed 7 months ago by scott.gonzalez

See #2188 for another test case.

Changed 4 months ago by robyn

change line 1067 in jquery-uncompressed.js (version 1.2.3)

from

else if ( value == undefined && jQuery.browser.msie && jQuery.nodeName( elem, "form" ) && (name == "action" || name == "method" ) )

to

else if ( value == undefined && jQuery.browser.msie && jQuery.nodeName( elem, "form" ) && (name == "action" || name == "method" || name == "id") )

this will solve the problem :)

Changed 3 months ago by flesler

  • status changed from new to closed
  • resolution set to fixed

Fixed at [5574], check #2548.

Note: See TracTickets for help on using tickets.