Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Javascript: adding 'false' after running a function

I'm analyzing a plugin as I want to modify it. I see various events firing functions like this:

    document.getElementById(this.config.form).addEventListener("submit", this._submit, false);

My question is - what does false on the end actually do? Is it the same as adding return = false on the end of a function? If so, what is the purpose of adding this?

like image 832
Allen S Avatar asked May 30 '26 03:05

Allen S


1 Answers

It's useCapture variable.

If true, useCapture indicates that the user wishes to initiate capture. After initiating capture, all events of the specified type will be dispatched to the registered listener before being dispatched to any EventTarget beneath it in the DOM tree. Events which are bubbling upward through the tree will not trigger a listener designated to use capture. See DOM Level 3 Events for a detailed explanation. If not specified, useCapture defaults to false.

See MDN.

like image 139
antyrat Avatar answered May 31 '26 18:05

antyrat



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!