What's the effect of adding 'return false' to a click event listener?

前端 未结 16 1958
南旧
南旧 2020-11-21 22:59

Many times I\'ve seen links like these in HTML pages:

Click here !
16条回答
  •  野的像风
    2020-11-21 23:28

    You can see the difference with the following example:

    Google
    

    Clicking "Okay" returns true, and the link is followed. Clicking "Cancel" returns false and doesn't follow the link. If javascript is disabled the link is followed normally.

提交回复
热议问题