Dom node added event method:
document.getElementById("myBtn").addEventListener("click", function(){
document.getElementById("demo").innerHTML = "Hello World";
});
grammar:
element.addEventListener(event, function, useCapture)
Parameter Value
parameter | description |
---|---|
event | have to. String that specifies the name of the event. Note: Do not use the "on" prefix. For example, use "click", instead of "onclick". Tip: All HTML DOM events, you can check out our full HTML DOM Event Object Reference Manual . |
function | have to. Specify the function that executes when the event is triggered. When the event object as the first argument passed to the function. Type of event object depends on the particular event. For example, "click" events were MouseEvent (mouse event) object. |
useCapture | Optional. Boolean value that specifies whether the event in the capture or bubbling phase. Possible values:
|
Event event delivery parameters
When passing a parameter value, use function calls with arguments "anonymous function":
E.g:
let scope = ‘123’;
this.dom.addEventListener('mousedown', function (){
scope.onMouseDown(event,scope);
},
false);