Jump to content

Event Listener


jimfog

Recommended Posts

I am confused with some terms javascript uses. Suppose i have a button element which in it there is an onclick event corresponding to a javascript function. Obviously i am describing an event here. Question: What is an event listener? Is it the function waiting to be called upon the button clicking? Thanks for a patience. P.S Javascript is a difficult language to master-i wonder who thought of a syntax like that?

Link to comment
Share on other sites

A listener is waiting for an event to happen, and to delegate accordingly. It waits for the button to get clicked, and when it does, tells the element to execute any code assigned to it's click event. Maybe there are more technical descriptions, but that's the general over view. A lot of this comes into play with event bubbling. Personally I don't the syntax is that hard to understand, and I certainly appreciate its flexibility. Try and code some similar things in Java vs. Javascript and you will get the idea, haha. by my last comment, clearly there aren't event handlers in java, but I'm saying the amount of code to write your basic loops and control structures and just to get it off the ground; there in lies the beauty of JS for me.

Link to comment
Share on other sites

In my view, an event listener is a built-in, behind-the-scenes object of sorts that waits for a specific event to happen. The listener is beyond the reach of a developer aside from being able to bind them to elements through the use of addEventListener or the traditional on[event] properties.When an event happens, the listener passes the event to an event handler. The handler would be the function(s) that is assigned to an event. I'm with scientist on the JavaScript syntax. I personally don't find it very challenging and rather enjoy the power and flexibility you have.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...