Solution 1 :

Marquee cannot change direction while running. You have to stop it, change direction then start again, but it will start from the beginning

This said, marquee is deprecated.DO NOT USE IT.

You can (and should) use CSS animations, like shown here:

Once implemented, you can use javascript to change the css animation.

Solution 2 :

If you are trying to stop the animation change this:




You can also restart with:


Problem :

I’m trying to change the attribute, “scrollamount” to 0 in a javascript function for a Marquee Tag. However, it seems to have no effect on the scrolling animation. My original settings are set to scroll up at a scrollamount of 4.
I’ve tried to change it in Javascript with:


and without quotes


The strange thing this is if I try to change the “direction” attribute it seems to respond.


If I to change the attribute “behavior” to alternate, the text disappears. I think its there somewhere but is getting pushed, for whatever reason, out of the DIV container


I’m new to this and I’m trying to understand. I feel like this should work in theory based on the things I have read about changing attributes and it seems to work for one attribute but not the others. Any help would be appreciated.

Here is my codepen:


Comment posted by Rob Moll

Are you trying to stop or pause the animation on a click?

Comment posted by Pacifico

Yes, I’m trying to stop the animation so that the Id’s of the clicked object appear on the LED screen. When I use stop() it freezes but if i stop the animation while part of the text is outside the container it will stay there and not recenter itself. If I change the scrollamount to 0 in the html it does what I want. The problem is I can’t change the attribute in my javascript function for some reason.

Comment posted by Rob Moll

Even though I posted an answer below – @Vol wisely points out the deprecation in HTML5. His advice is sound.

Comment posted by Pacifico

Ok, I’ll play around with this method. Would deprecation explain explain why the attribute wouldn’t change?

Comment posted by…

Found this: “Marquee cannot change direction while running. You have to stop it, change direction then start again, but it will start from the beggining.” Source:

Comment posted by Pacifico

That does work for the most part. The problem is when using stop() the text stops exactly where the text is at that moment and not centered to the container. Perhaps there is a way to center the text after stop(). Is there a reason why my function isn’t affecting the attribute?

Comment posted by Rob Moll

@Pacifico to answer your question regarding why your function was not working, You needed to use


Leave a Reply

Your email address will not be published. Required fields are marked *