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:https://www.quackit.com/css/codes/marquees/.

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

Solution 2 :

If you are trying to stop the animation change this:

document.getElementById("ledtxt").scrollamount=0;

to

document.getElementById("ledtxt").stop();

You can also restart with:

document.getElementById("ledtxt").start();

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:

document.getElementById("ledtxt").scrollamount="0";

and without quotes

document.getElementById("ledtxt").scrollamount=0;

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

document.getElementById("ledtxt").direction="down";

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

document.getElementById("ledtxt").behavior="alternate";

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:

https://codepen.io/Pacman0006/pen/rNaRZNJ

Comments

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 stackoverflow.com/questions/34267073/…

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

By

Leave a Reply

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