Change onClick attribute with javascript

后端 未结 6 1114
执笔经年
执笔经年 2020-12-02 16:35

This is my function and it should change the onClick attribute of the HTML input, but if I use

document.getElementById(\'buttonLED\'+id).onclick = \"writeLED         


        
6条回答
  •  庸人自扰
    2020-12-02 17:38

    Well, just do this and your problem is solved :

    document.getElementById('buttonLED'+id).setAttribute('onclick','writeLED(1,1)')
    

    Have a nice day XD

提交回复
热议问题