Implement MooTools Element.getSiblings()

By  on  

Update: I've added the "match" option to the getSiblings() method.

While browsing through the open tickets at the MooTools LightHouse, I found this little gem proposed by SixtyMonkey:

Element.implement({
	getSiblings: function(match,nocache) {
		return this.getParent().getChildren(match,nocache).erase(this);
	}
});

The above code grabs all sibling elements (the collection of alike elements minus the "found" one.) Do you think this should be added to the core?

I submitted this to core and it has been accepted. Look forward to seeing this in core!

Recent Features

Incredible Demos

Discussion

  1. hello david!

    i was wondering when this method would becomes part of the core? in MooTools 2 perhaps? or would you guys do something like MooTools 1.2.4 or something?

  2. It is – just not documented

  3. Arjan

    little typo

    nocash -> nocache

Wrap your code in <pre class="{language}"></pre> tags, link to a GitHub gist, JSFiddle fiddle, or CodePen pen to embed!