1$( "div.enterleave" )
2 .mouseenter(function() {
3 n += 1;
4 $( this ).find( "span" ).text( "mouse enter x " + n );
5 })
6 .mouseleave(function() {
7 $( this ).find( "span" ).text( "mouse leave" );
8 });
1let test = document.getElementById("test");
2
3// This handler will be executed only once when the cursor
4// moves over the unordered list
5test.addEventListener("mouseenter", function( event ) {
6 // highlight the mouseenter target
7 event.target.style.color = "purple";
8
9 // reset the color after a short delay
10 setTimeout(function() {
11 event.target.style.color = "";
12 }, 500);
13}, false);