Add event to button with javascript

后端 未结 4 1242
忘掉有多难
忘掉有多难 2020-12-18 23:24

In this page there\'s a way to dynamic add html (textbox,input button and radio elements with javascript

my questioon is how can i add an event to the button, imagi

4条回答
  •  有刺的猬
    2020-12-18 23:43

    Probably the easiest cross-browser way is to set the event name as a property of the element:

    Element.onclick = function () 
    {
       // do something...
    }
    Element.onmouseup = function () 
    {
       // do something else...
    }
    

提交回复
热议问题