Opened 12 years ago
Closed 12 years ago
#9798 closed bug (invalid)
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: | ||
Blocked by: | Blocking: |
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 (1)
comment:1 Changed 12 years ago by
Component: | unfiled → attributes |
---|---|
Priority: | undecided → low |
Resolution: | → invalid |
Status: | new → closed |
Note: See
TracTickets for help on using
tickets.
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-*.