Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hover Over to Pause Marquee

Tags:

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 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?

like image 422
Howdy_McGee Avatar asked Sep 17 '11 04:09

Howdy_McGee


People also ask

How do I stop marquee on mouse over?

Stop Marquee on Hover We acheive this by using the onmouseover event. More specifically, we use onmouseover="this. stop();" . To start it again, we use the onmouseout event (i.e. onmouseout="this.

How do you pause a marquee in HTML?

Start/Stop Buttons: You can add "start" and "stop" buttons that enable the user to start and stop the marquee as required. To do this, simply add an "id" attribute to the marquee, then reference that from your buttons (created using the input tag). Go on... press the button!

What is Scrolldelay in marquee?

The Marquee scrolldelay attribute in HTML is used to set the interval between each scroll movement in milliseconds. The default value of Scrolldelay is 85.

How do you control marquee speed?

Marquee speed can be changed using the "scrollmount" attribute. For example, if you are using scrollmount="1" then it sets the marque to scroll very slowly, and as you increase the "scrollmount," the scrolling speed will also increase. Marquee can also be implemented using CSS.


Video Answer


2 Answers

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

You're using wrong case: onMouseOver,onMouseOut

like image 190
Leo Avatar answered Nov 07 '22 15:11

Leo


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);
    });
});
like image 34
wesbos Avatar answered Nov 07 '22 14:11

wesbos