Implement Element.getSiblings() in MooTools »
p>也许,您比较熟悉jQuery siblings()方法,它的作用是:取得一个包含匹配的元素集合中每一个元素的所有唯一同辈元素的元素集合,返回匹配元素集合。
这个方法非常有用的,但是MooTools中是如何实现的,我们看一下:
1 2 3 4 5 | Element.implement({ getSiblings: function(match) { return this.getParent().getChildren(match).erase(this); } }); |