Twitter Button and Twitter API

Hi there,
I really need help to understand how it is possible to post a quote (a simple <p> that is static and not dynamic) on Twitter.

This is my project on CodePen. I understood how to use in JS and wich is the Twitter url to use.

See the Pen #1 DayOfCode: Twitter Button by Mauro Bono (@KubuniWebDesign) on CodePen.

I’d like to understand how to modify this to post on Twitter my quote:

    $("#tweet").click(function() {"")  });

Thanx a lot!


Basically you need to assign your quote to a variable:

var quote = “My Quote”;

and just add this variable in your url

$("#tweet").click(function() {“” + quote ) });

Obviously accessing the quote from the DOM is a different kind of thing.

Thank you! I solved with these lines:

  $("#tweet").click(function() {

    var a = $("#myQuote").html();"" + a)

But now I have another problem, why if a want to post on Twitter the content of the h1 in the div it, with a variable like

`var a = $(“h1”).html();

It post on Twitter alla the content in the div itself???`