The $()
and $$()
functions are the bread and butter of MooTools. When you're working with unobtrusive JavaScript, you need to specify which elements you want to operate on.
The dollar and dollars functions help you do just that, they will allow you to specify what elements you want to work on.
The dollar function is used for getting an element by its ID, which returns a single element that is extended with MooTools Element methods or null if nothing matches. Let's go back to awesomeParagraph
in the earlier example. If I wanted to select awesomeParagraph
, this is what I would write:
$('awesomeParagraph')
By doing so, we can now operate on it by passing methods to the selection. For example, if you wanted to change its style to have a color of red, you can use the .setStyle()
method which allows you to specify a CSS property and its matching...