Home > front end >  Please help to take a look at this js, what's the problem, thanks to answer
Please help to take a look at this js, what's the problem, thanks to answer

Time:10-10

Rolling/* */
Roll (50);

The function roll (t) {
Var ul1=document. GetElementById (" comment1 ");
Var ul2=document. GetElementById (" comment2 ");
Var ulbox=document. GetElementById (" review_box ");
Ul2. InnerHTML=ul1. InnerHTML;
Ulbox. ScrollTop=0;
Var timer=setInterval (rollStart, t);
Ulbox. onm ouseover=function () {
clearInterval(timer);
}
//mouse after removed div continue rolling
Ulbox. onm ouseout=function () {
The timer=setInterval (rollStart, t);
}
}
//start rolling function
The function rollStart () {
//the above statement of the DOM object for local objects need again
Var ul1=document. GetElementById (" comment1 ");
Var ul2=document. GetElementById (" comment2 ");
Var ulbox=document. GetElementById (" review_box ");

If (ulbox scrollTop & gt; Ul1. ScrollHeight) {
Ulbox. ScrollTop=0;
} else {
Ulbox. ScrollTop++;
}

}

/* rolling over */

This is a table up circularly js, in general, no problem, also can stop the mouse moved to scroll, but sometimes, the mouse in the content, refresh a few times more, moving the mouse can't stop rolling events would happen, rolling speed is slightly slow, really don't know the specific reason

CodePudding user response:

Online, etc.,,,,

CodePudding user response:

You change the onm ouseover and onm ouseout to onm ouseenter, onm ouseleave, onm ouseover and onm ouseout trigger child elements

CodePudding user response:

refer to the second floor JiexC0la response:
you change the onm ouseover and onm ouseout to onm ouseenter, onm ouseleave, onm ouseover and onm ouseout trigger quilt element
thank you for answer, but still have this case, to can't stop rolling

CodePudding user response:

When set the timer first to empty a clearInterval (timer); According to the normal situation over and out will be interleaved execution but sometimes may be the exception; SetInterval before you perform a clearInterval (timer) should be ok
  • Related