Home >Web Front-end >JS Tutorial >Introduction to the difference between the href and onclick events of a tag_Basic knowledge

Introduction to the difference between the href and onclick events of a tag_Basic knowledge

WBOY
WBOYOriginal
2016-05-16 17:27:531048browse

1. The onclick event is executed first. If the onclick event returns a false value, the href will no longer be executed.
2. href="#" defaults to the anchor point #top, so the page will jump to the top when there is a scroll bar. The best solution is href="javascript:void(0);".
3. The returned content in href will flush out the information of the current page.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn