What is the Difference between onclick and href="[removed]function name?

前端 未结 6 1678
别跟我提以往
别跟我提以往 2021-02-10 12:20

Is there any difference between

1 : Link1

and

2 : 

        
6条回答
  •  离开以前
    2021-02-10 12:43

    If your website requires Javascript in order to function correctly then Javascript in the href is best because it shows the link in the status bar and keeps the code compact. In the href also serves keyboard navigation without the mouse. If your website is required to function without Javascript then you have to use onclick so the href can have a link in it. Adding the action in a separate Javascript file fails to keep code & data bound tightly.

提交回复
热议问题