-5

I'd like to understand something in this code:

<a id="btn_save" href="#" onclick="return false;" title="">Save</a>

Where does the return onclick="return false;" go to?

Jason P
  • 26,984
  • 3
  • 31
  • 45
bigjel
  • 57
  • 8

2 Answers2

0

Returning false from an event handler is a way of telling the browser that you want to prevent the default action associated with the link.

Michał Dudak
  • 4,923
  • 2
  • 21
  • 28
0

You are disabling the default function of the click event by returning false on click.

for example :

<a id="btn_save" href="http://www.google.com" onclick="return false;" title="">Save</a>

Even though the points to google.com, when you click the link , it won't take you to google.com. i.e. the default action is returned false.

It's similar to event.preventDefault()

mohamedrias
  • 18,326
  • 2
  • 38
  • 47