Some background: I'm working on Front-End Development FreeCodeCamps projects, and this project is a random quote station.
I would like to leave the author hidden for each quote, but at the moment the "Click to Reveal" button only opens the author of every other quote ...
https://codepen.io/DecisiveIndecisive/pen/KXjXXd
This code is Javascript. Thanks!
$(document).ready(function() { var url = "https://api.forismatic.com/api/1.0/?method=getQuote&key=1&lang=en&format=jsonp&jsonp=?"; $("#refreshButton").on("click", function() { $.getJSON(url, function(json) { var jsonQuote = json.quoteText; var jsonAuthor = json.quoteAuthor; $(".counter").html(jsonAuthor); $("#authorButton").text("Click to Reveal"); if (jsonAuthor === "") { $("#refreshButton").trigger("click"); } else { $(".message").html(jsonQuote); $("#authorButton").click(function() { $(this).text(function(i, text) { return text === "Click to Reveal" ? "- " + jsonAuthor : "Click to Reveal"; }); }); }
source share