Opened 12 years ago
Closed 12 years ago
#8820 closed bug (invalid)
attr("any",undefined) returns undefined
Reported by: | fergusg | Owned by: | |
---|---|---|---|
Priority: | undecided | Milestone: | 1.next |
Component: | unfiled | Version: | 1.5.2 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
Example (in Chrome debugger):
jQuery("<a>").attr("href",undefined).css("a","b"); TypeError: Cannot call method 'css' of undefined
I would expect the same behaviour as attr("...",null), which returns the jQuery object.
Change History (2)
comment:1 Changed 12 years ago by
comment:2 Changed 12 years ago by
Resolution: | → invalid |
---|---|
Status: | new → closed |
Thanks for taking the time to contribute to the jQuery project! Passing undefined to attr is treated the same as not passing any value at all, thus treated as a getter. Use http://api.jquery.com/removeAttr to remove attributes.
Note: See
TracTickets for help on using
tickets.
See: http://jsfiddle.net/2CPXk/ (that's only up to jQuery 1.5.1, but the same problem)