Tweet a random quote

Tweet a random quote
0.0 0


Hi guys,
I am trying to tweet the random quote i get from an API and i don’t know what is wrong.
i declare a global variable var tweet_quote= $(’.quote ‘).text and use it in the the JQuery code to tweet it. When i try to console.log this varieble everything goes fine. When h try to open the window(
$(’#tweet’).on(‘click’, function(){""+tweet_quote);

) this way i cannot tweet it.
Here is my codepen project :

Thanks for the help, Christos


At the start when you define tweet_quote there is no quote loaded yet. If you put the tweet_quote = $('.quote1').text(); inside the event handler it should work. Also, it should be ""+tweet_quote with the text parameter.

You will still have to format the string so it doesn’t break when there is a semi-colon (or other non-alphanumeric characters) inside.


everything works fine . Thanks for the help!!!