Help with Twitter Button - Quote Machine - SOLVED

Hi! I need help with Twitter Button. Here is my code for the quote machine http://codepen.io/Ddorab/pen/YpoQom and I think the problem must be here:
$("#tw").click(function(){$(“a”).attr(“href”, “https://twitter.com/intent/tweet/?text=” + " " + qarr[x][0] + " " + " - " + qarr[x][1]);
}); …
But I can’t figure it out.
Thank you!!!

You’re so close. All you have to do is use jQuery to get the quote text from the div and assign it to a variable. See below:

$("#tw").click(function(){
    var Quote = $("#quote").text();
    var Author = $("#author").text();
  $("a").attr("href", "https://twitter.com/intent/tweet/?text=" + " " + Quote + " " + " - " + Author);
  });

Thank you for your reply!!
I added thise lines in the function, but still not working.

You have to get rid of the button tag on line 22 of your html. It’s not actually being used for anything.

Oh yes. I hadn’t notice that it was useless. Thanks a lot!!! It works now . :slight_smile:

1 Like