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

前端 未结 6 1068
夕颜
夕颜 2021-02-10 11:55

Is there any difference between

1 : Link1

and

2 : 

        
6条回答
  •  我在风中等你
    2021-02-10 12:42

    The onclick version allows you pass 'this' as an argument, so you can refer back to the tag/object the click came from. Not possible with the protocol method:

    yo yo yo
    

    will spit out an alert popup with "yo yo yo", whereas

    yo yo yo
    

    will spit out 'undefined'.

提交回复
热议问题