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

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

Is there any difference between

1 : Link1

and

2 : 

        
6条回答
  •  日久生厌
    2021-02-10 12:46

    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'.

提交回复
热议问题