何时以及为何在JavaScript中“返回false”? [英] When and why to 'return false' in JavaScript?

查看:108
本文介绍了何时以及为何在JavaScript中“返回false”?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

何时以及为什么在JavaScript中返回false

推荐答案

通常,在事件处理程序中,例如 onsubmit ,返回false是一种告诉事件实际不会触发的方法。因此,比如说,在 onsubmit 的情况下,这意味着表单未提交。

Often, in event handlers, such as onsubmit, returning false is a way to tell the event to not actually fire. So, say, in the onsubmit case, this would mean that the form is not submitted.

这篇关于何时以及为何在JavaScript中“返回false”?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆