SoFunction
Updated on 2025-03-10

Introduction to the difference between the events of href and onclick in a tag

Introduction to the difference between the events of href and onclick in a tag

Updated: July 26, 2013 17:58:55 Author:
I believe everyone is familiar with the href and onclick events of the tag A tag. As for the difference between them, do you know? Let me introduce you below. Interested friends can learn it. I hope it will be helpful to you.
1. The onclick event is executed first. If the onclick event returns a false value, href will no longer be executed.
2. href="#"The default page goes to the anchor point #top so when there is a scroll bar on the page, it will jump to the top. The best solution is href="javascript:void(0);".
3. The returned content in href will flush out the information of the current page.
  • aTag
  • href
  • onclick

Related Articles

  • JavaScript If...Else Statement

    JavaScript If...Else Statement...
    2007-04-04
  • AngularJS directive detailed introduction

    This article mainly introduces AngularJS directives. Here we introduce the knowledge of AngularJS directives in detail and provide example code. Friends who need it can refer to it.
    2016-07-07
  • Ajax does not execute success callback but executes error callback

    Recently, I am reading jQuery API documentation. When using jQuery's ajax, if the dataType is specified as json, I always do not execute the success callback, but execute the error callback function, which is extremely depressed
    2012-12-12
  • Basic javascript syntax

    This article explains the basic syntax of javascript through operators, expressions, statements, functions, objects, events, and variables. Friends who need it can refer to it.
    2016-05-05
  • A brief discussion on the types of JavaScript function functions

    This article mainly introduces the types of JavaScript function functions, including ordinary functions, anonymous functions, closure functions, and is very comprehensive, and is attached with examples. I recommend it to you here, hoping it will be helpful to you.
    2014-12-12
  • JavaScript Advanced Programming (3rd Edition) Study Notes 5 js statements

    The following is a similar form to sort out the relevant knowledge of the statement, focusing on some special and interesting aspects in ECMAScript. Similarly, the statements that are not emphasized but are relatively basic are not unimportant, but I think you are already familiar with them.
    2012-10-10
  • Introduction to the use of sub() method in JavaScript

    This article mainly introduces the use of sub() method in JavaScript, which is the basic knowledge in JS introduction. Friends who need it can refer to it.
    2015-06-06
  • JavaScript uses EventListener to HTML DOM

    This article mainly introduces JavaScript's method of using EventListener to operate HTML DOM. It is used to add events to HTML elements. Friends who need it can refer to it.
    2015-10-10
  • JAVASCRIPT function scope and advance declaration Share

    This article introduces the scope and early declaration of JAVASCRIPT function. Friends who need it can refer to it.
    2013-08-08
  • Shell scripts implement Linux system and process resource monitoring

    This article mainly introduces the implementation of the monitoring of Linux system and process resource in Shell scripts. This article explains how to check whether the process exists, detect the process CPU utilization, detect the process memory usage, and detect the process handle usage. Friends who need it can refer to it.
    2015-03-03

Latest Comments