web-dev-qa-db-ja.com

マーキーを一時停止するには、カーソルを合わせます

いくつかのニュース記事をスクロールするMarqueeを作成したいのですが、ユーザーがその上にホバーしたときに一時停止する必要があり、ユーザーがそこからホバーしたとき(onMouseOut)、最初に戻る必要があります。これは機能しませんでした:

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

最小限のコードでこれを実現する方法について何か提案はありますか?

13
Howdy_McGee

マーキータグには、その速度を制御するscrollamountという属性があります。カーソルを合わせるときに値を0に設定し、マウスアウトすると値を5に戻すだけです。

デモ: http://jsfiddle.net/U9yFj/

$(function() {
    $('Marquee').mouseover(function() {
        $(this).attr('scrollamount',0);
    }).mouseout(function() {
         $(this).attr('scrollamount',5);
    });
});
18
wesbos
<Marquee onmouseover="this.stop();" onmouseout="this.start();">
my text here
</Marquee>

間違ったケースを使用しています:onMouseOver、onMouseOut

32
Leo
<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タグを使用しているユーザーに役立つことを願っています。

4
Abbas
<Marquee behavior="scroll" direction="left" onmouseover="this.stop();" onmouseout="this.start();">
    Go on... hover me (and hold the mouse over)!
</Marquee>
3
Fadi
<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>
2
Nipek

HTMLマーキーマークアップは、

onmouseover="stop()"

に続く

onmouseout="start()"
0
Jiwan

追加する必要があります;を閉じた後、コードに()

0
RAHUL RAWAT