Passing parameters in Javascript onClick event

前端 未结 9 1009
滥情空心
滥情空心 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:14

    or you could use this line:

     link.setAttribute('onClick', 'onClickLink('+i+')');
    

    instead of this one:

    link.onclick=  function() { onClickLink(i+'');};
    

提交回复
热议问题