Skip to main content

Bug Tracker

Side navigation

#7107 closed bug (invalid)

Opened October 01, 2010 01:10PM UTC

Closed October 01, 2010 04:12PM UTC

calling $(this).attr('children') returns blank list

Reported by: longears Owned by:
Priority: undecided Milestone: 1.4.3
Component: attributes Version: 1.4.2
Keywords: 'children' attribute Cc:
Blocked by: Blocking:

I have an element:

<button class="delete" children="6">delete</button>

I have a click listener on the button:

$('button.delete').live('click', deleteTask);

In my deleteTask() method I am unable to access the "children" attribute of my button:


When Output $(this).attr('children') to the console it gives me this:


This is the same behavior as if I were to try to output an attribute that doesn't exist.

Attachments (0)
Change History (2)

Changed October 01, 2010 03:00PM UTC by jitter comment:1

This bug is invalid IMHO.

The reason for your problem has two main causes:

  • children is no valid html/xhtml attribute for button
  • children is (although not defined by any standard but available in all current browsers) a DOM attribute of the button element and holds all child element nodes of the button.

So when you call $(this).attr('children') jQuery accesses the DOM attribute and not the (invalid) HTML attribute and you get back an empty HTMLCollection.

If I may give you an advise don't use invalid attributes or at least choose a name which doesn't collide with existing DOM attributes.

Your are better off using jQuery data() to store custom data on element

Changed October 01, 2010 04:12PM UTC by john comment:2

resolution: → invalid
status: newclosed