Passing parameters in Javascript onClick event

前端 未结 9 1054
滥情空心
滥情空心 2020-12-02 09:43

I\'m trying to pass a parameter in the onclick event. Below is a sample code:

9条回答
  •  无人及你
    2020-12-02 10:32

    It is probably better to create a dedicated function to create the link so you can avoid creating two anonymous functions. Thus:

    Although in both cases you end up with two functions, I just think it is better to wrap it in a function that is semantically easier to comprehend.

提交回复
热议问题