选框问题

Issue with Marquee

本文关键字:问题      更新时间:2023-09-26

html 如何使用 JavaScript 停止 marquee 元素?

<marquee behavior="alternate" direction="right">hello</marquee>

当我将鼠标放在它上面时,我想停止移动文本 hello。

谢谢。

您可以简单地添加内联行为更改:

<marquee behavior="alternate" onmouseover="this.scrollAmount = 0" 
onmouseout="this.scrollAmount=10" direction="right">hello</marquee>

演示

演示 - http://jsfiddle.net/h4ww3jsv/

<marquee onmouseover="this.stop();" onmouseout="this.start();" behavior="alternate" direction="right">hello</marquee>

下面的代码在Mozilla v27上不起作用

<marquee behavior="alternate" onmouseover="this.scrollAmount = 0" 
onmouseout="this.scrollAmount=10" direction="right">hello</marquee>

此问题的解决方案是使用以下代码

<marquee onMouseOver="this.setAttribute('scrollamount', 0, 0);" OnMouseOut="this.setAttribute('scrollamount', 6, 0);">Hello</marquee> 

小提琴:http://jsfiddle.net/3kedfyos/3/

我建议也阅读 https://developer.mozilla.org/en-US/docs/Web/HTML/Element/marquee