Hi! I have some issues figuring out how to do this (like, at all), and I’d greatly appreciate being pointed in the right direction. :D
I’m working on a generator with multiple outputs. Now, I know how to update them on click separately, no big deal. What I want for this generator is one output that auto-updates every few seconds to display a different item from its list.
Let’s say the list’s name is “quote” and the output div’s ID is “quotes”. (Not linking the generator in question because it’s too work-in-progress-y and full of placeholders)
(One day I’ll be proficient enough in JavaScript to figure these things out by myself, I swear!)
Thank you so much in advance!
https://lemmy.world/post/11402472 what you want in plugin form
setInterval(function(){update(quotes)},1000)
Thank you! :D
deleted by creator
deleted by creator
You will likely get better answers by posting your code, especially to a coding specific help forum like stack overflow.
Anyways, try this: https://developer.mozilla.org/en-US/docs/Web/API/setInterval
I googled this before I came here to ask, and I know that setInterval exists and that it’s what I need to use, I just don’t know how to make it update from my Perchance list. I also don’t think stack overflow is the best place to ask a question about Perchance. I read pretty much all somewhat related questions and answers there before I came here to ask. Maybe I should’ve mentioned that in my OP.
You can update a specific element by referencing their id on the
update()
function like so:update(id)
.So, using the
setInterval
, you can dosetInterval(() => update(id), 2000)
which will update every two seconds.Here is a example generator which also shows how to add and stop intervals.
Edit: There is also this example from the Perchance Examples page.
HOW did I miss the example generator?? I’m so sorry! I looked through the advanced tutorials and examples, but must’ve tunnel-vision’d away from the solution.
Thank you so much for the explanation, that’s just perfect!