Random Quote Machine Twitter Link Issue Using Plain JS

Alright, so I’ve beaten my head against the wall for the past two days on this and scoured every similar post on the subject to no avail. So here is my Issue. I’ve gotten everything to work as intended when the page initially loads(I’ve made the quote window a jumbo button of sorts). The first quote that comes up when the page loads, you can click on the tweet button and it populates in the tweet window just fine. It is after you generate a new quote on the page, the twitter quote portion won’t update with it if you try and tweet the subsequent new quotes. It remains on the first one that triggered on the page load. From what I understand it has to do with how the function is triggered (native function call vs. call via .eventListener). If anyone could throw me a bone here I’d greatly appreciate it. Thank you to everyone for your time.
Below is my codePen. https://codepen.io/themiestro/pen/qVXGzw

First, your code executes the randomGenerator function which assigns a new quote to the filteredQuotes variable. Second, you add a click event handler for the box. Third, you set the href attribute of the anchor element with id=“xmit” to the value filteredQuotes has in it.

You never replace the href of the the anchor element with id=“xmit” again in your code, so the whatever href you set for the anchor stays the same no matter how many times you generate a new quote with the click of the box.

1 Like

Thanks for your timely reply Randell. Let me see if I can wrap my head around this. I’m pretty sure I understand what you are saying, it’s just a matter of whether I can tinker with my code effectively enough to translate it from narrative to code form.