Hover Over to Pause Marquee

前端 未结 7 2068
无人及你
无人及你 2021-01-08 00:29

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 to ti s

相关标签:
7条回答
  • 2021-01-08 00:52

    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);
        });
    });
    
    0 讨论(0)
提交回复
热议问题