Question

Can someone please help me to understand what exactly is the "Event" and "Event handler" in following examples? According to www.w3schools.com here is the list of some common events

enter image description here

so why some people still keep saying Click event handler? is Click event or event handler?

1.

$( "p" ).click(function() {
       alert("Which One is Event and which one Event Handler");
});
$("p").on("click",function(){
       alert("Which One is Event and which one Event Handler");
});
$("p").css("background-color","yellow");
Était-ce utile?

La solution 2

Following your code:

$("p").click(function() {
    // this function is the event handler of the "click" event
});

which is the same as:

$("p").on("click",function(){
   alert("Which One is Event and which one Event Handler");
});

(see jQuery on documentation)

The following code, is not an event, just changes the style of the p elements:

$("p").css("background-color", "yellow");

Autres conseils

The event is the action. The handler is the receiver of that action, usually a function.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top