Hello! I have this bit of code set up for my pretty neat quote generator challenge project:
$("button").click(function() {
$(".theQuote").slideUp("slow", function() {
$.getJSON("https://talaikis.com/api/quotes/random/", function(chosenQuote) {
$(".quote").text(chosenQuote.quote);
$(".author").text(chosenQuote.author);
});
})
.delay(500);
$(".theQuote").slideDown("slow");
});
It’s meant to:
- Operate on the click of the button
- Slide the div up, hiding the old quote
- Get the random quote API I chose
- Insert the new quote in the old quote’s place
- Slide the div down, revealing the new quote
It works! But whenever I click the button, sometimes it runs twice, or three times. It does the whole thing, sliding up, changing the quote, and sliding back down. Does anyone see the reason why this is? I’m a little baffled.