jQuery 在鼠标悬停时停止选取框并在鼠标悬停时播放

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6160092/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 20:29:33  来源:igfitidea点击:

stop marquee on mouseover and play on mouseout

jqueryhtml

提问by booota

I am using the conventional marquee html tag in my site:

我在我的网站中使用传统的 marquee html 标签:

<marquee direction="left"><div id="logo-scroll">
    <ul id="clients-logos">
        <li><a href="#"><img src="images/logos/alcatel.jpg" alt="Alcatel" /></a></li>
        <li><a href="#">abs</a></li>
    </ul>
 </div></marquee>

how can i pause marquee through jquery on mouseover and mouseout events keeping in mind that i want to work with marquee tag not jquery script.

我怎样才能通过 jquery 在 mouseover 和 mouseout 事件上暂停选取框,记住我想使用选取框标签而不是 jquery 脚本。

Thanks

谢谢

回答by Andy E

Use the startand stopmethods:

使用startstop方法:

$("marquee").hover(function () { 
    this.stop();
}, function () {
    this.start();
});

Working demo: http://jsfiddle.net/ZWQqc/

工作演示:http: //jsfiddle.net/ZWQqc/

Just noticed your last line — jQuery provides the mouseenterevent to non-IE browsers here, making life much easier. You should keep your JavaScript separate from your HTML because it's much easier to maintain.

刚刚注意到你的最后一行——jQuery 在mouseenter这里为非 IE 浏览器提供了事件,让生活变得更轻松。您应该将 JavaScript 与 HTML 分开,因为它更易于维护。