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

前端 未结 14 1638
说谎
说谎 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:14

    Usage of javascript:void(0) means that the author of the HTML is misusing the anchor element in place of the button element.

    Anchor tags are often abused with the onclick event to create pseudo-buttons by setting href to "#" or "javascript:void(0)" to prevent the page from refreshing. These values cause unexpected behavior when copying/dragging links, opening links in a new tabs/windows, bookmarking, and when JavaScript is still downloading, errors out, or is disabled. This also conveys incorrect semantics to assistive technologies (e.g., screen readers). In these cases, it is recommended to use a

    Source: MDN's Page.

提交回复
热议问题