Ticket #11116 (closed bug: invalid)
Trying to set attribute selected to anything sets it to "selected"
| Reported by: | r_rom@… | Owned by: | r_rom@… |
|---|---|---|---|
| Priority: | low | Milestone: | None |
| Component: | attributes | Version: | 1.7.1 |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
Description
In my code I use img elements as tabs, and to track their states I've used an attributes that they aren't normally supposed to have: selected. I set this attribute to true or false based on the state. This used to work, but with some version it broke, and I've discovered this with version 1.7.1 of jQuery. What happens now is that when I try to set this attribute to *anything* at all, it ends up getting set to "selected".
I can change my code to work around this, but I wanted to report this because the change in jQuery has broken my previously working code.
Change History
comment:1 Changed 17 months ago by sindresorhus
- Owner set to r_rom@…
- Status changed from new to pending
comment:2 Changed 17 months ago by timmywil
- Priority changed from undecided to low
- Resolution set to invalid
- Status changed from pending to closed
- Component changed from unfiled to attributes
This is intended behavior. "selected" is the only valid value for the selected attribute. For further explanation and to familiarize yourself with a better way to work with boolean attributes, see http://api.jquery.com/prop/.
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

Thanks for taking the time to contribute to the jQuery project! Please provide a complete reduced test case on jsFiddle to help us assess your ticket.
Additionally, be sure to test against the jQuery Edge version to ensure the issue still exists. To get you started, use this boilerplate: http://jsfiddle.net/FrKyN/ Open the link and click to "Fork" (in the top menu) to get started.