Quote machine tweet button and click event not working

Quote machine tweet button and click event not working
0

#1

I’m currently working on the Quote Machine…

Firstly, the tweet button doesn’t show up as it’s meant to… I’ve looked at this website for reference https://dev.twitter.com/web/tweet-button as well as other people’s codepens (I even tried copying someone else’s code just to see if it showed up, but it doesnt - all I can see is the text…)

Second is when I try to add the click event so that the text changes when clicking the button. I wanted to see if it worked before trying to put any extra code in, but nothing happens. I literally followed the example from fcc.


#2

Codepen uses iframes to display your code and they do not allow displaying external websites within this iframe, so you need your links to jump out of the iframe and into a new window. The easiest way to do this is add target="_blank" to the anchor tag with class=“twitter-share-button”.


[quote="juliasjoberg, post:1, topic:167383"] Second is when I try to add the click event so that the text changes when clicking the button. I wanted to see if it worked before trying to put any extra code in, but nothing happens. I literally followed the example from fcc. [/quote] Nothing happens, because you are using jQuery syntax but have not added the jQuery library to Codepen's external JS files. Click on the settings gear of the JS module and do a Quck-add and select jQuery from the dropdown. Once you do this, you can click on the Get new quote button and it will change the text to "Test replace".

#3

Hey juliasjoberg,

It looks like you are using some jQuery in your code, but your Codepen is not including the jQuery library. To fix this, go to Settings > Javascript in your Codepen and add the jQuery library through the “Add External Scripts/Pens” search box. Doing so should at least fix the click event, let us know how it goes from there :slight_smile: