Reputation: 601
I have a quote machine which displays random movie quotes. Now I'm trying to add the name of the movie underneath the quote using jquery but it's not working for some reason. I tried following what others have done on their own quote machine projects or modifying snippets in my own code but I can't seem to figure it out.
Code I've tried:
function getQuote() {
var randomIndex = Math.floor(Math.random() * quotes.length);
var selectedQuote = quotes[randomIndex];
$('#main-quote').text(selectedQuote.quote);
var selectedBG = selectedQuote.background;
console.log(selectedBG);
$("body").css("background-image", "url('" + selectedBG + "')");
$('#main-quote').text(selectedQuote.quote);
var selectedMovie = selectedQuote.movie;
console.log(selectedMovie);
$("#what-movie").html("selectedMovie");
}
Thank you!
Upvotes: 0
Views: 33
Reputation: 82241
You have wrapped the variable selectedMovie
in quotes, which makes it as text. simply remove the quotes and every thing will fall in place:
$("#what-movie").html(selectedMovie);
Upvotes: 3