jQuery“eq()”相当于什么?在 Mootools 中?

发布于 2024-12-15 07:14:14 字数 196 浏览 3 评论 0原文

我是 Mootools 的新手,并且已经使用 jQuery 一段时间了。我想做的是将一些 jQuery 转换为 mootools。

我用 jQuery 编写了以下内容:

var title = $('a:eq(2)').attr('title');

您如何在 mootools 中编写等效内容?

I am new to Mootools and have been using jQuery for a while. What I am trying to do is convert some jQuery into mootools.

I have the following written in jQuery :

var title = $('a:eq(2)').attr('title');

how would you write the equivalent in mootools?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

在你怀里撒娇 2024-12-22 07:14:14

Mootools 文档有答案,使用 :index() 选择器:

$('a:index(2)');       // Gets the third <a> tag.

要检索标题属性,请使用 getProperty

var title = $('el').getProperty('title');

注意。这适用于 MooTools Core v1.4.1

Mootools docs have the answer, use the :index() selector:

$('a:index(2)');       // Gets the third <a> tag.

To retrieve the title attribute use getProperty:

var title = $('el').getProperty('title');

NB. This applies to MooTools Core v1.4.1

云仙小弟 2024-12-22 07:14:14

您可以使用双美元函数,它返回与您提供的元素类型匹配的元素数组 -

var title = $('a')[2].title;

演示 - http://jsfiddle .net/wWbmC/

更多信息

http://mootools.net/blog/2010/ 03/19/更好的使用元素的方法/
http://solutoire.com/2007/09/20/understanding-mootools-selectors-e-and-es/

You could use the double dollar function, which returns an array of elements matching the element type you supply -

var title = $('a')[2].title;

Demo - http://jsfiddle.net/wWbmC/

Further Info

http://mootools.net/blog/2010/03/19/a-better-way-to-use-elements/
http://solutoire.com/2007/09/20/understanding-mootools-selectors-e-and-es/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文