我的网站上有一个marquee :
<marquee>Hello! <span id="text">Welcome to my website.</span></marquee>我想从marquee中用id="text"改变span的内容:
setTimeout(function() { document.getElementById("text").innerHTML = "This is my website. Happy reading!"; }, 5000);<marquee>Hello! <span id="text">Welcome to my website.</span> </marquee>一切运作良好。 问题是我想在更改文本后从头开始重新启动选取框。 想象一下,第一个文本是一个较长的文本,当与另一个文本进行更改时,它在第一次滚动时不会完全可读; 访客将从中间看到它。
所以,我想从头开始重新启动选框滚动。
谢谢!
I have a marquee on my website:
<marquee>Hello! <span id="text">Welcome to my website.</span></marquee>I want to change dynamically the content of the span with id="text" from marquee:
setTimeout(function() { document.getElementById("text").innerHTML = "This is my website. Happy reading!"; }, 5000);<marquee>Hello! <span id="text">Welcome to my website.</span> </marquee>All works well. The problem is that I want to restart the marquee, from the beginning after changing the text. Imagine first text is a longer one, when changing with another, it will not be entirely readable at first scroll; the visitor will see it from middle.
So, I want to restart the marquee scroll from beginning.
最满意答案
也许不是你想要或期望的。 但这应该重新开始。 我将使用新元素删除并重新插入DOM中的选取框。
setTimeout(function() { document.getElementById("marquee").innerHTML = '<marquee>Hello! <span id="text">This is my website. Happy reading!</span></marquee>'; }, 5000);<div id="marquee"> <marquee>Hello! <span id="text">Welcome to my website.</span> </marquee> </div>Maybe not what you want or expect. But this should restart the marquee. I would delete and reinsert the marquee in the DOM with a new element.
setTimeout(function() { document.getElementById("marquee").innerHTML = '<marquee>Hello! <span id="text">This is my website. Happy reading!</span></marquee>'; }, 5000);<div id="marquee"> <marquee>Hello! <span id="text">Welcome to my website.</span> </marquee> </div>
更多推荐
发布评论