Can anyone offer a little help please. I have a tweet button that is linking to and sharing the page rather than the quotes and I’m a little stuck on how to fix this.
Thanks for your suggestions and help the other day, with a little help I manged to sort the problem , however I have another issue you might be able to help with.
I have appeneded an initial quote to my /< p >/ element that I’d also like users to be able to tweet before clicking on the get quote button.
How can I include this as part of the tweet function I already have? I have a feeling I should be using an if/else statement in there somewhere but unsure how to go about it.
I did create another function to do this, but thinking about the D.R.Y principle reminded me there must be a better way.
The problem is that your tweet button’s event listener is inside your ‘next quote’ button’s event listener. So, you have to click on that button first to attach the click event to you tweet button. Try to move it outside of that block.
A few other things… I’ve noticed you used jQuery, and although I haven’t used it in the last few years, I think append() is to add nodes/DOM elements and you should use a simple .text() to add your first quote. And I’d also swap the .html()s with .text()s, unless you get an HMTL string in response from the API.
Oh, and if you already use it, you can use jQuery in your tweet() function, instead of vanilla JS.