The difference between the href and onclick events of the a tag

  • 2020-03-30 04:19:29
  • OfStack

The javascript differences in onclick are generally not noticed, but are somewhat frustrating when something goes wrong, as the text chapter explains:

It used to be very casual until I saw linkbutton in.net. A href = "javascript: fun ();" . > Today, in this way to meet some problems, the article and my conclusion is put in the following:

[why]
When using the CheckBoxList control, you want to add a link after each checkbox. Click on the link to do more than that.

< Input type = "checkbox" name = "CHK" id = "CHK" >
< The label for = "CHK" > Select it < A onclick = "this. ParentNode. Click ();" Href = "#" style = "border: 1 px blue solid;" > [link in label]< / a> < / label>

Finally, it is implemented by parentNode.

< A href = "javascript: void (0)" onclick = "defineField (this); Return false "> ClickToDefine< / a>


Related articles: