Skip to main content

Bug Tracker

Side navigation

#8820 closed bug (invalid)

Opened April 08, 2011 09:21AM UTC

Closed April 08, 2011 02:34PM UTC

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.

Attachments (0)
Change History (2)

Changed April 08, 2011 09:27AM UTC by fergusg comment:1

See: http://jsfiddle.net/2CPXk/ (that's only up to jQuery 1.5.1, but the same problem)

Changed April 08, 2011 02:34PM UTC by timmywil comment:2

resolution: → invalid
status: newclosed

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.