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?
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.
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!
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.
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.
<marquee onmouseover="this.stop();" onmouseout="this.start();">
my text here
</marquee>
You're using wrong case: onMouseOver,onMouseOut
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);
});
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With