Building a random quote generator

Building a random quote generator


I am having trouble with the tweet button populating the quote correctly. I believe it is happening in this part of the code

$(’#tweet-btn’).click(function() {‘’ + $(’#quote’).text() + " " + $(’#author’).text());

When the code encounters a semi colon character within the quote it stops and doesn’t upload the rest of the quote, or the author. Anyone have any ideas on how to fix it? I provided a link below for the quote generator. Click through the generator until you find a quite with a semi colon and then click the tweet button and see what populates in the input field and you will see what the problem is. Thanks for the help.


It looks like you can fix it by using the jQuery ‘replace’ function (assuming it’s only that character that’s causing issues). I think this works

  $('#tweet-quote').click(function() {'' + '\"'+ $("#quote").text().replace(/;/, '%3B') + '\"' + ' -'+$('#author').text());


You are awesome! That worked. I appreciate the help.

#4"" + $("#quote").html());

the #quote was a p element. So i can easily get its text like this. You can also include your author in there too by adding +" "+ (if needed) then +author.


This solution still causes the original problem. Once the quote gets to the semi colon it cuts off. The solution that r1chard5mith has recommended actually solved the issue. Thank you for responding to my request for help.