Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

addEventListener overwrites other event actions?

Does addEventListener overwrites previously defined actions for a particular event?For example,

<input type="text" name="ele" id="eleID" onfocus="doSomeThing();"/>

Now if I add another action for the same event,will both both function get executed?

eleID.addEventListener('focus',doSomethingElse,false);

If doSomethingElse() overwrites doSomeThing(), is there any other way to do it?

like image 656
Rookie Avatar asked Jun 03 '11 13:06

Rookie


1 Answers

No.

From MDC:

addEventListener is the way to register an event listener as specified in W3C DOM. Its benefits are as follows:

  • It allows adding more than a single handler for an event.

See example.

like image 134
lonesomeday Avatar answered Sep 19 '22 09:09

lonesomeday