Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Learning Objectives
By the end of this lecture, you should be able
to:
Learn to use the hover() function
Work with the event object
Improve your familiarity with the API
},
function() {
//SECOND anonymous function for mouseout
$(this).css('color','black');
} //anonymous function for mouseout
); //closing ) for hover() function
FILE: hover_with_menu.htm
Recall that with our previous anonymous functions, we did not provide any arguments to our
anonymous function. In those examples, the identifier function( ) contained nothing inside
the parentheses.
However, if we want to use the event object, we must provide an argument to our anonymous
function. The identifier I will give to this argument is evt. (I will avoid calling it event since
this is a reserved keyword in some languages).
So in this case, our anonymous function will look like this: function(evt)
Now we can use this evt identifer to find out information about our mouse click event. And to
reiterate, the identifier does not have to be evt just be sure that you choose an identifier
that is clear. I believe that evt serves our purpose just fine, and many programmers use it.
Also note in the example above, we use the selector document. This means that the entire
web page serves as our selector instead of, say, a specific tag or ID.