Href= ' javascript:function () ' and onclick can have the same effect, in general, if you want to invoke the script or write code in the onclick event, but not recommended in href= ' javascript:function () ' This way, because the href attribute is set in the JS code, in some browsers may cause other unnecessary events. Cause unintended effects.
And the onclick event will be executed first than the HREF attribute, so it will trigger the onclick and then trigger the href, so if you do not want the page to jump, you can set the onclick inside the JS code execution to return a false, so that the contents of the href will not be executed.
In an AJAX application, write the following to indicate that the link does not jump and executes a JS script.
<a href= "javascript:void (0)," onclick= "function ()" ></a>
or <a href= "javascript:;" onclick= "function ()" ></a>
void (0) is only used to calculate a null value, but in fact it is nothing to do, and the semicolon ";" is an empty JS statement, so that no other jumps occur, and the standard is not recommended to execute JavaScript inside the href, so it is best to use the OnClick event trigger
"Go" onclick event differs from href= ' javascript:function () '