Random Quote Generator - cannot extract quote to the Twitter window

Random Quote Generator - cannot extract quote to the Twitter window
0

#1

Hi! I absolutely have no idea why my code to set the new HREF doesn’t work (so that the tweet?text= would contain the quote). Could someone help me please? Thanks in advance!

Here is the project on codepen so far:
https://codepen.io/kwidyani/pen/prmVwa


#2

Hey. First of all, you may want to add jQuery in the pen settings. Without it, the .attr() method you are using to set the new URL can’t work.

Then, you can decide to keep the inline “onclick” you have in your HTML or the .click() jQuery method. If you decide to keep the jQuery method, you’ll have to write the function call without parenthesis like so: .click(genQuote).

Finally, remove the “.twitter-share-button” class from the anchor (you can use the Bootstrap classes “btn btn-primary” to style it as a button). That class is used by the script you added (widget.js) and it’s messing things up. Also, you can’t add the hashtags via attribute, just add it to your url like so:

"https://twitter.com/intent/tweet?text=" + quote + "&hashtags=quote"


#3

Thank you so much noyb!

re: adding hashtags via attribute, it actually worked yesterday, so i guess it worked because I had the “twitter-share-button” class? I don’t see how it’s related though…

Any idea what that widget.js script does? I got it from the twitter developer resources but don’t understand why it’s there!