I have an array containing a number of statements/quotes but I would like to add some custom HTML to help style each quote when they are displayed.
In the below code I have demonstrated what I'd like to do but at the moment the actual HTML tags are output as strings. How do I get them to render as HTML so I can style them with CSS?
Here's a working fiddle showing what I mean: https://jsfiddle.net/tawasnng/1/
// Random testimonials headlines = new Array('Food was amazing and the drinks well-priced. We’ll be back soon!<span class="boom">Test</span>', "Bad", "Ugly", "Random Headline"); var randomNumberBefore = 4;
function randomNumberByRange (range, number) {
var r = Math.floor(Math.random() * (range-1));
if(r >= number)r++;
return r; }
$(document).on('click','.nextquote' , function() {
var randomNumber = randomNumberByRange( headlines.length, randomNumberBefore);
randomNumberBefore = randomNumber;
var nextHeadline = headlines[randomNumber];
$(".quote").text(nextHeadline);
});