where does the return of onclick="return false" go

where does the return of onclick="return false" go?

本文关键字:return quot false go onclick does the of where      更新时间:2023-09-26

我想理解这段代码中的一些东西:

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

返回的onclick="return false;"去了哪里?

通过在单击时返回false来禁用单击事件的默认功能。

例如:

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

即使指向google.com,当你点击链接时,它不会把你带到google.com。即默认操作返回false。

类似于event.preventDefault()

从事件处理程序返回false是告诉浏览器您希望阻止与该链接关联的默认操作的一种方式。