使用 jQuery 在 JavaScript 中设置延迟悬停时循环代码
我希望通过 jQuery 悬停事件来启动和停止具有设定延迟的循环。我一直试图用“鼠标悬停”和“鼠标移出”来做到这一点,但没有成功。
示例(奇怪的伪代码):
Mouseover
Loop
Change text colour
Wait 100ms
Mouseout
Stop loop
我确信这非常简单,我只是不太知道如何用 JavaScript 构建它。
提前致谢。
I'm looking to start and stop a loop with a set delay with a jQuery hover event. I've been trying to do it with "mouseover" and "mouseout" with no luck.
Example (odd psudocode):
Mouseover
Loop
Change text colour
Wait 100ms
Mouseout
Stop loop
I'm sure this is super easy, I just don't quite know how to structure it with JavaScript.
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
这可能有效:
请参阅实际操作: http://www.jsfiddle.net/YjC6y/19/< /a>
This might work:
See this in action: http://www.jsfiddle.net/YjC6y/19/
尝试一个例子:http://jsbin.com/uraxe4
try an example : http://jsbin.com/uraxe4
此处的工作示例:
http://jsbin.com/etogi3/2
working example here:
http://jsbin.com/etogi3/2