Bug Tracker

Modify

Ticket #9894 (closed bug: worksforme)

Opened 2 years ago

Last modified 2 years ago

jQuery attr() returns undefined in Firefox/Chrome when used on the attribute "value".

Reported by: ivolodin@… Owned by:
Priority: low Milestone: 1.6.2
Component: attributes Version: 1.6.1
Keywords: Cc:
Blocking: Blocked by:

Description

It looks like function attr has been modified in jQuery 1.6.1 to use attrHooks collection. Because of that, if you are trying to retrieve a value of the "value" attribute, it executes the code that does element.value. Line 2193 in jQuery forks the code so that for the attributes within attrHooks it wouldn't use element.getAttribute() function. "value" is allowed attribute for some elements, like input fields, and you can get it through element.value, but for elements like "div" it's a custom attribute, and you can't retrieve it through .value. Please look at the link attached for an example.

Sample here:  http://jsfiddle.net/gd2Ms/1/

Change History

comment:1 Changed 2 years ago by timmywil

  • Priority changed from undecided to low
  • Resolution set to worksforme
  • Status changed from new to closed
  • Component changed from unfiled to attributes
  • Milestone changed from None to 1.6.2

Works fine in latest version of jQuery:  http://jsfiddle.net/timmywil/gd2Ms/2/

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

View

Add a comment

Modify Ticket

Action
as closed
Author


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

 
Note: See TracTickets for help on using tickets.