We'll be using the same HTML document, but this time, let's explore the dollars function:
We're going to select the last list item (it has a class of
lastItem)
. Using the.getFirst()
, we select the first element from the array$$()
returned. Then, we're going to use the.get()
method to get its text. To show us what it is, we'll pass it to thealert()
function. The code to write to accomplish this is:alert( $$('.lastItem').getFirst().get('text') );
Save the HTML document and view it in your web browser (or just hit your browser's refresh button if you still have the HTML document from the preview Time for action open). You should now see the following: