1

I'm attempting to use mootools' .getFirst(); to select (naturally) the first element that matches a particular CSS3 selector. However, it doesn't seem to work, and I am forced to fall back to using .getElement();, which also works as intended.

http://jsfiddle.net/NdWs9/

Note that .getElement(); returns the <li> element while .getFirst(); does not.

Anyone have any ideas?

1
  • The description of the argument says it all: "match - (string, optional): A full CSS selector to match the found element(s) with.". There is nothing wrong with the way the method works. Oct 19, 2011 at 19:08

2 Answers 2

1

Unfortunately it seems like getFirst is not recursive, which means that for your example to work you'll have to update it to $('foo').getFirst('* li');.

http://jsfiddle.net/mqchen/NdWs9/2/

0
1

It seems that you are correctly using getElement, as it "Gets the first descendant element whose tag name matches the tag provided. CSS selectors may also be passed." and incorrectly using getFirst, which get the First Element (not descendant).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.