Many related articles can be found in js dynamic addition events, but few parameters can be passed. Below is a good example to meet your requirements for parameter passing, do not miss out.
The Code is as follows:
Var tt = function (obj)
{
Return function ()
{
Alert (obj. tagName); // an execution function that can be defined externally;
}
}
Function addfunction ()
{
Var bigobj = document. getElementById ("mytable ");
Var rows = bigobj. rows;
For (var j = 0; j {
For (var I = 0; I {
Rows [j]. cells [I]. attachEvent ("onmousemove", tt (rows [j]. cells [I]);
// Rows [j]. cells [I]. onmousemove = function (){
// Tt ();
//}
}
}
}
=========== Compatible with FF and IE
The Code is as follows:
Function addEvent (o, c, h ){
If (o. attachEvent ){
O. attachEvent ('on' + c, h );
} Else {
O. addEventListener (c, h, false );
}
Return true ;}
Var tt = function (obj)
{
Return function () {textChange (obj );}
}
AddEvent (input1, "change", tt (input1 ));
Function textChange (o)
{
// Do something
}
If Jquery is used, it can be done in one sentence.
$ ("Input [type = 'text']"). change (function (){
// Here you can write some verification code
});