Bug Tracker

Modify

Ticket #9798 (closed bug: invalid)

Opened 23 months ago

Last modified 23 months ago

selected attr defined on div returns undefined for .attr()

Reported by: drd Owned by:
Priority: low Milestone: None
Component: attributes Version: 1.6.2
Keywords: Cc:
Blocking: Blocked by:

Description

Starting with 1.6.1, having a "selected" attribute on a <div> or <p> element returns undefined when using .attr() to retrieve the value of the attribute

jsFiddle:  http://jsfiddle.net/zRmQL

Given: <div id="div1" selected="div1selected">

Executing: $('#div1').attr('selected') returns undefined

This was also true for a 'value' attribute in 1.6.1 but that appears to have been corrected in 1.6.2.

The code works as expected (returns the value of the attribute) in 1.5.2 and prior releases

Change History

comment:1 Changed 23 months ago by timmywil

  • Priority changed from undecided to low
  • Resolution set to invalid
  • Status changed from new to closed
  • Component changed from unfiled to attributes

You will see in the git version of jQuery that the behavior consistently checks for attribute existence, but the boolean attributes in attr work for where they are valid. This is why, in the git version, you will see "selected" returned rather than your custom value. In other words, selected should not be used on a div. The valid way to do custom attributes is with  data-*.

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.