Is there any last() in YUI NodeList?
Is there any last() in YUI NodeList?
假设我尝试选择YUI3中节点列表的最后一个子节点:
var node = Y.one('#node');
node.all('button').last(); // pseudo-code, not actually working!
是否有一个相当于jquery的last()
(和first()
分别)在YUI3?
我检查了API文档,没有找到任何可比的。
node.one('button:last-child')
也不行
one('button:last-child')
应该工作。请看这个例子。然而,:last-child
是指它的父的最后一个子,所以它是高度依赖于你的DOM结构。
<ul>
<li><button>Foo</button></li>
<li><button>Bar</button></li>
<li><button>Baz</button></li>
</ul>
<script>
Y.one('button:last-child'); // yields <button>Foo</button>
// should be written like so
Y.one('li:last-child button');
</script>
我看不到,但这似乎可以完成工作:
var links=Y.all("a"),
lastLink=links.item(links.size()-1)
详情请参阅http://yuilibrary.com/yui/docs/api/classes/NodeList.html#method_item
相关文章:
- Node.js's Buffer.writeFloatBE in Javascript
- Setting default onclick behavior for <img> tag in gene
- Lucene Search in Alfresco
- grep in JQuery to C#
- 如何在屏幕外或项目的中心视口中跟随YUI驱动的动画
- write HTML in JavaScript
- jQuery setTimeOut: in for-loop
- SetTimeout and clearTimeout in Javascript
- 鼠标输入在 YUI 的 chrome 中不起作用
- lightbox in html 5 and javascript
- 使用KnockoutJS绑定的YUI DataTable
- HTMLInputElement in IE7
- Mongodb$in以与数组中相同的顺序获取结果
- element.dataset in Internet Explorer
- jQuery parent() in table
- Instagram oauth flow in angularjs
- In循环的In运算符前后
- 如何使用for in循环在javascript中显示对象中的对象
- Is there any last() in YUI NodeList?
- onChange in YUI