Reputation: 1331
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?
Upvotes: 0
Views: 813
Reputation: 265547
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
Upvotes: 3
Reputation: 24236
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/
Upvotes: 2