将鼠标悬停在暂停选取框上

发布于 2024-12-05 07:49:55 字数 309 浏览 1 评论 0原文

我想创建一个滚动一些新闻文章的选框,但是当用户将鼠标悬停在它上面时,我需要它暂停,当用户将鼠标悬停在它外面(onMouseOut)时,我需要它启动备份。这不起作用:

<marquee onMouseOver="this.stop()" onMouseOut="this.start()">Text</marquee>

有人对如何用最少的代码实现这一目标有任何建议吗?

I want to create a Marquee that scrolls some news articles but when the user hovers over it I need it to pause and when the user hovers out of it (onMouseOut) I need it to start back up. This did not work:

<marquee onMouseOver="this.stop()" onMouseOut="this.start()">Text</marquee>

Does anyone have any suggestions on how I can achieve this in a minimal amount of code?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(8

酒绊 2024-12-12 07:49:55
<marquee onmouseover="this.stop();" onmouseout="this.start();">
my text here
</marquee>

您使用了错误的大小写:onMouseOver、onMouseOut

<marquee onmouseover="this.stop();" onmouseout="this.start();">
my text here
</marquee>

You're using wrong case: onMouseOver,onMouseOut

烧了回忆取暖 2024-12-12 07:49:55

marquee 标签有一个名为 scrollmount 的属性,它控制它的运行速度。我们需要做的就是当鼠标悬停时将值设置为 0 ,并在鼠标移出时将其设置回 5

演示:http://jsfiddle.net/U9yFj/

$(function() {
    $('marquee').mouseover(function() {
        $(this).attr('scrollamount',0);
    }).mouseout(function() {
         $(this).attr('scrollamount',5);
    });
});

The marquee tag has an attribute called scrollamount which controls how fast it goes. All we need to do is set the value to 0 when we hover in and set it back to 5 when we mouse out.

DEMO: http://jsfiddle.net/U9yFj/

$(function() {
    $('marquee').mouseover(function() {
        $(this).attr('scrollamount',0);
    }).mouseout(function() {
         $(this).attr('scrollamount',5);
    });
});
我最亲爱的 2024-12-12 07:49:55
<marquee behavior="scroll" direction="left" onmouseover="this.stop();" onmouseout="this.start();">
    Go on... hover me (and hold the mouse over)!
</marquee>

<marquee behavior="scroll" direction="left" onmouseover="this.stop();" onmouseout="this.start();">
    Go on... hover me (and hold the mouse over)!
</marquee>

阳光下的泡沫是彩色的 2024-12-12 07:49:55
<marquee behavior="scroll" scrollamount="5" direction="left" onmouseover="this.setAttribute('scrollamount',0);" onmouseout="this.setAttribute('scrollamount',5);">
 Your name, your address, your details scrolling through line
</marquee>

希望这段代码对使用 MARQUEE 标签的人有所帮助。

<marquee behavior="scroll" scrollamount="5" direction="left" onmouseover="this.setAttribute('scrollamount',0);" onmouseout="this.setAttribute('scrollamount',5);">
 Your name, your address, your details scrolling through line
</marquee>

Hope this code will help someone who is use MARQUEE tag.

盗梦空间 2024-12-12 07:49:55
<marquee id="mq" direction="right" loop="true" onmouseover="this.stop();" onmouseout="this.start();">
    <a href="http://google.com">Google</a>
    <input type="text" id="txt" />
    <input type="button" id="btn" value="Click here" onclick="alert(txt.value);" />
    Some other text here</marquee>
<marquee id="mq" direction="right" loop="true" onmouseover="this.stop();" onmouseout="this.start();">
    <a href="http://google.com">Google</a>
    <input type="text" id="txt" />
    <input type="button" id="btn" value="Click here" onclick="alert(txt.value);" />
    Some other text here</marquee>
俏︾媚 2024-12-12 07:49:55

您可以简单地使用 HTML 选取框标记,

onmouseover="stop()"

然后是

onmouseout="start()"

You can simply use the HTML marquee markup with

onmouseover="stop()"

followed by

onmouseout="start()"
百善笑为先 2024-12-12 07:49:55

关闭 () 后,您必须将 ; 添加到代码中。

You have to add ; to your code after closing the () .

等数载,海棠开 2024-12-12 07:49:55

虽然 onmouseover 和 onmouseout 函数可能在某些浏览器上工作。

请注意,字幕标记已过时,可能已失效

在这个语义html时代,我们应该使用html来构建内容。 CSS 应该用于视觉样式,如果需要,CSS 应该由 Javascript 提供支持。

CSS3 实现字幕效果的方式。

Although the onmouseover and onmouseout function may work on some browser.

Please note that marquee tag is outdated and can say dead.

In this era of semantic html we should use html to structure content. CSS should be sued for Visual styling and if required the CSS should be powered by Javascript.

CSS3 way of achieving marquee affect.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文