What if we wanted to select multiple sets of elements and run the same method (or methods) on them? Let's do that now.
Let's select the list item that has an
<a>
element inside it and the last list item (class="lastItem"
), and then animate them to the right by transitioning theirmargin-left
CSS property using the.tween()
method.Right below the line we wrote previously, place the following line:
$$('li a, .lastItem').tween('margin-left', '50px');
View your work in your web browser. You should see the second and last list item move to the right by 50 pixels.
We explored the dollar and dollars functions to see how to select different elements and apply methods to them. You just learned to select:
An element with an ID
(#listItem and #superList)
using the dollar$()
functionAn element with a class (
.lastItem
) using the dollars$$()
functionMultiple elements by separating them with commas
(li...