Javascript – Chaining selectors in jQuery


I'm a guy used to mootools' way of chaining selectors, and I can't seem to find anywhere how to do the same in jQuery.
Suppose I have a select element in the selectObj variable. What I need is to get the last option in that select.
In mootools I would have done something like:

var option = $(selectObj).getElement('nth-child(last)')

Can I do something similar, or what is the way of getting that last option in jQuery?

PS. I know about the parent > child selector, but I can't really use it because I don't know what selector has been used to get the select. I only have the resulting element.

Best Solution


You can use find to perform another query within the current query.

In general, you can check out the Selectors and Traversal pages on jQuery docs when you're trying to figure out how to select something.