How to set onclick with javascript?

前端 未结 4 584
萌比男神i
萌比男神i 2021-02-05 07:20

I am trying to set the onclick event using javascript. The following code works:

var link = document.createElement(\'a\');
link.setAttribute(\'href\', \"#\");
l         


        
4条回答
  •  太阳男子
    2021-02-05 07:32

    Use sth like this if you like:

    
    

提交回复
热议问题