Home > front end >  Js event binding problem
Js event binding problem

Time:09-27

Have taken to the DOM, but unable to bind mouse events, the console display onm ouseover event undefined

CodePudding user response:

How to bind an event, you send the code

CodePudding user response:

https://blog.csdn.net/Oriental_/article/details/104676772

CodePudding user response:

reference 1/f, the sky wave response:
how do you bind the event, send the code to see

Window. The onl oad=init;
The function the init () {
//encapsulating a substitute for the getElementById () method of
The function byId (id) {
Return typeof (id)==="srting"? Document. The getElementById (id) : id;
}
//global variable
Var index=0,
The timer=null;

The function slideImg () {
Var main=byId (main);
//slip timer, left to continue
The main onm ouseover=function () {
//slip remove timer
}
The main onm ouserout=function () {
The timer=setInterval (function () {
index++;
The console. The log (index);
}, 3000);
}
}

SlideImg ();

}
</script>

CodePudding user response:

refer to the second floor Oriental_ response:
https://blog.csdn.net/Oriental_/article/details/104676772

Thank you, thank you very much

CodePudding user response:

reference weixin_45769528 reply: 3/f
Quote: reference 1/f, the sky wave response:
how do you bind the event, sending the code to see

Window. The onl oad=init;
The function the init () {
//encapsulating a substitute for the getElementById () method of
The function byId (id) {
Return typeof (id)==="srting"? Document. The getElementById (id) : id;
}
//global variable
Var index=0,
The timer=null;

The function slideImg () {
Var main=byId (main);
//slip timer, left to continue
The main onm ouseover=function () {
//slip remove timer
}
The main onm ouserout=function () {
The timer=setInterval (function () {
index++;
The console. The log (index);
}, 3000);
}
}

SlideImg ();

}
</script>

The console showed my onm ouseover event undefined

CodePudding user response:

String to quotes
Var main=byId (" main ");

CodePudding user response:

Another onm ouseout spelling mistakes

CodePudding user response:

refer to 7th floor sky waves reply:
and onm ouseout spelling mistakes

I changed as you said, is not an error, but also does not perform, the console and not every 3 seconds to print a index??

CodePudding user response:

refer to the eighth floor weixin_45769528 response:
Quote: refer to 7th floor sky waves reply:
and onm ouseout spelling mistakes

I changed as you said, is not an error, but also does not perform, the console and not every 3 seconds to print an index?

"String" is also a spelling mistake

CodePudding user response:

references 9/f, the sky wave response:
Quote: refer to the eighth floor weixin_45769528 response:

Quote: refer to 7th floor sky waves reply:
and onm ouseout spelling mistakes

I changed as you said, is not an error, but also does not perform, the console and not every 3 seconds to print an index?

"String" is misspelled

Solved, thank you very much,
  • Related