0
  function foos()
  {
    return false;
  }

  function foo()
   {
     concole.log("Maizere");
   }


<div onclick="foo()">
    <button type="button" onclick="return foos()">Display Date</button>
</div>

Return false is not cancelling the event propagation ,but is said that it also prevents event propagation. Have i misunderstood it?

Here is the reference

Maizere Pathak.Nepal
  • 2,383
  • 3
  • 27
  • 41

1 Answers1

2

By using the event object parameter in the foos function, you can call stopPropagation() on it:

  function foos(ev)
  {
    ev.stopPropagation();
    return false;
  }

Returning false on vanilla javascript event handlers won't prevent propagation. However, jQuery event handlers will prevent it.

Return false here, will prevent default behavious, such as navigation when pressing a link or submitting a form with a submit button.

Jørgen
  • 8,820
  • 9
  • 47
  • 67