Quote wont copy to tweet

Heya, so here’s my codepen for the project, and I have managed to get everything else working. I can’t figure out why my quote wont post into my tweet when it’s opened on another page. I even looked up a couple of examples of other peoples solutions, and I seem to be running along the same lines as them. Someone mind lending a hand?

@MarvinMerlin Your variable “quote” has local scope in the #execute onClick event.So, when you try to use “qoute” in the #twitter onClick event, it’s unreachable.

1 Like

Okay, so what should I do about that? I dont want to put the tweet event in the new quote click event, because then the button wont work.

Would it be enough if I pulled the quote variable out of the jquery, have it quote=(""); and then inside the event make it so that quoteBank[randomNumber] = quote("") ?

You can try this.

Declare your quote variable after the document ready, something like this…

$(document).ready(function() {

var quote = "";

// new quote
$("#execute").on(“click”, function(){
quote = “”;

Sweet baby jeebus it worked. Thanks @jamesperrin

No problem, glad I could help. With a lot of things, a fresh pair eyes always helps.

Totally, and thanks for the fast response. I had actually given up on this part of the project and moved on to the next one because the chat was so busy no one could take a second to look at my code.