Side navigation
#9798 closed bug (invalid)
Opened July 11, 2011 06:53PM UTC
Closed July 11, 2011 08:50PM UTC
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
Attachments (0)
Change History (1)
Changed July 11, 2011 08:50PM UTC by comment:1
component: | unfiled → attributes |
---|---|
priority: | undecided → low |
resolution: | → invalid |
status: | new → closed |
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-*.