$(function(){ // Get new quote button functionality $("#getQuote").on('click',function(){ $.ajaxSetup ({cache:false}); $(".message").animate({opacity:0}); $.getJSON("https://quotesondesign.com/wp-json/posts?filter[orderby]=rand&callback=", function(data) { $(".message").html(data[0].content + " — " + data[0].title).animate({opacity:1}); }); }); //Tweet button functionality $("#tweetIt").on('click', function(){ var phrase = $('.message').text(); var tweetUrl = "https://twitter.com/share?text=" + encodeURIComponent(phrase) + "." + "&url=" + "https://codepen.io/britoblanco"; window.open(tweetUrl); }); }); // My javaScript only solution did work with some limitations. /* var button = document.getElementById("clicker") var quotes = [ "\"I'm going to make him an offer he can't refuse.\" -The Godfather", "\"Houston, we have a problem.\" -Apollo 13", "\"You make me want to be a better man.\" -As Good as It Gets", "\"I'm just one stomach flu away from my goal weight.\" -The Devil Wears Prada", "\"Say \'hello\' to my little friend!\" -Scarface", "\"Here's Johnny!\" -The Shinning", "\"Hasta la vista, baby.\" -Terminator 2", "\"They call it a Royale with cheese.\" -Pulp Fiction", "\"The Dude abides.\" -The Big Lebowski"]; button.onclick = function () { var rand = quotes[Math.floor(Math.random() * quotes.length)]; document.getElementById("demo").innerHTML = rand; }; function tweetIt () { var phrase = document.getElementById('demo').innerText; var tweetUrl = "https://twitter.com/share?text=" + encodeURIComponent(phrase) + "." + "&url=" + "https://codepen.io/britoblanco"; window.open(tweetUrl); } /* // Solution 2 didn't work *************** /* var quotes = [ "\"I'm going to make him an offer he can't refuse.\" -The Godfather", "\"Houston, we have a problem.\" -Apollo 13", "\"You make me want to be a better man.\" -As Good as It Gets" ]; button.onclick = function () { for (var i = 0 ; i < quotes.length ; i++ ) { document.getElementById("demo").innerHTML = quotes[i]; return; } }; */ /* // My first 1 click reaction solution didn't work button.onclick = function () { document.getElementById("demo").innerHTML = "\"I'm going to make him an offer he can't refuse.\" -The Godfather"; }; */ //More quotes I need to iterate when onclick /* Houston, we have a problem. -Apollo 13 Say \"hello\" to my little friend! -Scarface Here's Johnny! -The Shinning Hasta la vista, baby. -Terminator 2 If you let my daughter go now, that'll be the end of it. I will not look for you, I will not pursue you. But if you don't, I will look for you, I will find you, and I will kill you. -Taken You make me want to be a better man. -As Good as It Gets I'm just one stomach flu away from my goal weight. -The Devil Wears Prada They call it a Royale with cheese. -Pulp Fiction Just when I thought I was out, they pull me back in. -The Godfather: Part III Wax on, wax off. -The Karate Kid I don't want to survive. I want to live. -12 Years a Slave It's alive! It's alive! -Frankenstein Help me, Obi-Wan Kenobi. You're my only hope. -Star Wars You is kind. You is smart. You is important. -The Help The Dude abides. -The Big Lebowski Just keep swimming. -Finding Nemo I'm the king of the world! -Titanic Roads? Where we're going we don't need roads. -Back to the Future Leave the gun. Take the cannoli. -The Godfather To infinity and beyond! -Toy Story You can't handle the truth! -A Few Good Men May the Force be with you. -Star Wars */

!