Hello,
I figured out how to pull a quote from an API and add it to my page and now I want to surround the quote with quotation marks. The problem is that when I add the marks to the string they get displayed on separate lines from the quote, like this:
“
random saying from famous person
”
Does anyone know how to fix this?
Here is the line where I declare the quote string:
var quote = “’” + a[0].content + “’”;
The quote you’re getting from the API (the value of a[0].content) is wrapped in p tags, so when you’re trying to add the quotation marks they’re displayed in your H1 tag while the quote is nested within the p tags. One option would be to slice off the p tags from a[0].content before you add the quotation marks.
The quotes look like they’re coming in surrounded by <p>
tags. You’ll probably do better by using CSS to insert :before and :after quotes and targeting that paragraph.
That was exactly the problem.
I just used the javascript String.replace() function to get rid of the tags and it looks good now.
Thank you both so much.
1 Like