For example:
In js, in order to add a button onclick event would write:
button.onclick
=
ClickEvent;
ClickEvent is a function.
In the absence of such ClickEvent parameter it is possible, but at the time ClickEvent need a parameter to die.
Then you can add like this:
button.attachEvent(
"
onclick
"
,
function
(){ClickEvent(event,
'
params
'
)});
Of course, this can also be added in the absence of the parameter, this is the best method.
There is another way:
div.addEventListener(
"
click
"
,ClickEvent);
In addition, setAttribute method does not work, no argument is not acceptable. [It is used to set the property of the object]
Reproduced in: https: //www.cnblogs.com/zhangchenliang/archive/2011/06/07/2074475.html