Skip to content

Instantly share code, notes, and snippets.

@chzyer
Last active December 10, 2015 22:48
Show Gist options
  • Save chzyer/4504538 to your computer and use it in GitHub Desktop.
Save chzyer/4504538 to your computer and use it in GitHub Desktop.
关于Javascript的return false;

由于时间紧急,先进入重点

当多层DIV层叠时,如果点击重叠处,发现ONCLICK事件会穿透所有层,也就是每一层的ONCLICK事件都会执行一遍。执行的顺序跟使用JQUERY绑定ONCLICK事件的顺序无关,执行的顺序始终从最上层往下。

问题来了,当只想让最上层的DIV接受ONCLICK而下层接收不到ONCLICK该怎么办。俗称把ONCLICK事件吃掉。没想到用return false可以达到这个效果,就这样,续待....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment