The differences between the href and onclick events of a tag are described in detail.
The differences between javascript in onclick are generally not noticed, but it is a little depressing when an error occurs. See the text chapter to explain it as follows:
I used to be casual. Later, let's take a look. the linkbutton in net seems to be used in <a href = "javascript: fun ();"...> in this way, I encountered some problems today. I picked some articles from netizens and put my conclusions below:
1. The onclick event of the link is executed first, followed by the action under the href attribute (page Jump, or javascript pseudo link );
2. Assume that both href and onclick exist in the link. If you want to disable the action under the href attribute, onclick must return a false value. Do not believe it. You can comment out return false in the goGoogle function;
3. If the page is too long with a scroll bar and you want to perform operations through the onclick event of the link. Set its href attribute to javascript: void (0); instead of #, which can prevent unnecessary page beats;
4. If a function with a returned value is called in the href attribute of the link, the content on the current page will be replaced by the returned value of this function;
5. The Shift key is different.
6. My problem today is that parentNode cannot be accessed in the form of href in IE6.0.
7. Try not to use javascript: As the href attribute of A. This will not only trigger the window. onbeforeunload event unnecessary, but also stop playing GIF animated images in IE.
In this case, it took a lot of time.
[Reason]
When using the CheckBoxList control, you want to add a link after each checkbox. In addition to some functions, you also need to select the checkbox.
<Input type = "checkbox" name = "chk" id = "chk">
<Label for = "chk"> select it <a onclick = "this. parentNode. click (); "href =" # "style =" border: solid 1px blue; "> [link in label] </a> </label>
Finally, it is implemented using parentNode.
<A href = "javascript: void (0)" onclick = "defineField (this); return false"> ClickToDefine </a>