Hello,
Both of the LinkedIn and Tweeter but don’t work. Tweet share the URL of my pen while LinkedIn generates a bank post.
I have used .attr() and given href with the attribute of the URL. Is there an error how I use the .attr()?
Hello,
Both of the LinkedIn and Tweeter but don’t work. Tweet share the URL of my pen while LinkedIn generates a bank post.
I have used .attr() and given href with the attribute of the URL. Is there an error how I use the .attr()?
I used this code for tweeting:
$('.twitter-share-button').click(function() {
var tweetQuote = $(".quote").text();
if (tweetQuote != '') {
window.open('https://twitter.com/intent/tweet?text="' + tweetQuote + '"', '_blank');
};
});
Note text= not ext=
Warning, spoiler! Fixed version (uses jQuery):
Thank you for your support but I am still lost.
Can you explain why?
I chaged the .attr() to window.open( url + var)
$(’#tweet’).on(“click”, function() {
var qtweet = $(".random").text();
window.open(‘https://twitter.com/intent/tweet?text=’ + qtweet);
});
But same is not working.
I think i missed an import point in freecodecamp tutorial?
Sorry, what is not working? If you look at my fork of your code, that works.
Here is the HTML.
<a href =“https://twitter.com/intent/tweet?text= " + tweetLink” class=" fa fa-twitter" data-size=“large” id = “tweet” target = “blank” >Tweet
Here is Javascript.
$(’.fa fa-twitter’).on(“click”, function() {
var tweetLink = $(".getQuoteButton").text();
window.open(‘https://twitter.com/intent/tweet?text= + tweetLink’ );
});
When I click the Twitter button the code sends a URL of Twitter only and not Quote.
eg.
https://twitter.com/intent/tweet?text=
Instead of
https://twitter.com/intent/tweet?text= random quote.