Reputation: 161
I need to add a link to a few quotes in a .js file that says "more". The link will redirect the user to the testimonials page where they can read the full testimonial. I'm not sure how to add a link directly in the .js file, because when I add an href it doesn't work. As you can tell, I'm not a Javascript guy, so please pardon my obvious stupidity :)
Here is the code for the quotes:
`({"quotes":
[
{
"quote" : "Quote 1 Here... <a href="/testimonials">more</a>",
"author" : "Persons Name"
}
]
})`
Upvotes: 0
Views: 1181
Reputation: 2060
If you need to put " inside the JSON data content, then you need to escape it, or use single quotes ', otherwise the double quotes in the middle will close the JSON value.
`({"quotes":
[
{
"quote" : "Quote 1 Here... <a href='/testimonials'>more</a>",
"author" : "Persons Name"
}
]
})`
But as stated above, you should do this by editing the object in javascript and reproducing the JSON in the correct format.
Upvotes: 0
Reputation: 887215
Your question doesn't make any sense. Javascript strings are ordinary strings and are not aware of any formatting details.
You probably want to set the HTML (not text) of a DOM element. Beware of the resulting XSS hole.
Upvotes: 1