cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

Quick-add: + add another resource

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

Quick-add: + add another resource

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

            
              


<head>

  <link href="https://fonts.googleapis.com/css?family=Lobster" rel="stylesheet">
</head>


<body>

  <h1 class="text-center text-primary text-center">Random Quote Machine</h1>

  <div class="row col-md-offset-4 col-md-4">

    <button class="btn btn-block btn-info" id="getQuote"> Give me a Quote</button>
  </div>

  <div class="row col-md-offset-1 col-xs-10 row well message" id="message">
    The quote will appear here


  </div>
  
  
    <a class="twitter-share-button" href="https://twitter.com/intent/tweet?text=Hello%20world" data-size="large" target="_blank" id="tweetButton">
    <button type="button" class="btn btn-primary">Tweet it!</button>
  </a>
  
  
</body>
            
          
!
            
              h1 {
  font-family: 'Lobster', cursive;
}

#message {
  text-align: center;
}

.btn {
  margin: 20px;
}
            
          
!
            
              
$(document).ready(function() {

   $("#getQuote").on("click", function(){
      
        var i = Math.floor((Math.random() * 29) + 1);
        $.getJSON("https://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=30&callback=", function(a) {

                  var Quote = a[i].content + a[i].title;             
                  $(".message").empty().append(Quote + "</p>");
                  var tweetQuote = $(Quote).text();
                  $("#tweetButton").attr('href', 'https://twitter.com/intent/tweet?text=' + encodeURIComponent(tweetQuote))}); //closes JSON function(a)

      }); //closes on"click"
 
}); //closes document ready
  
  
//now for the twitter button...


      
            
          
!
999px
Loading ..................

Console