What does “[removed]void(0)” mean?

前端 未结 14 1673
说谎
说谎 2020-11-21 15:23
login

I\'ve seen such hrefs many times, but I don\'t know what exactly

14条回答
  •  庸人自扰
    2020-11-21 16:10

    Web Developers use javascript:void(0) because it is the easiest way to prevent the default behavior of a tag. void(*anything*) returns undefined and it is a falsy value. and returning a falsy value is like return false in onclick event of a tag that prevents its default behavior.

    So I think javascript:void(0) is the simplest way to prevent the default behavior of a tag.

提交回复
热议问题