Change onClick attribute with javascript

后端 未结 6 1113
执笔经年
执笔经年 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:34

    Using Jquery instead of Javascript, use 'attr' property instead of 'setAttribute'

    like

    $('buttonLED'+id).attr('onclick','writeLED(1,1)')
    

提交回复
热议问题