123

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.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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.

+ add another resource

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              <body>
  <div class="container background">


  <h1 class="heading"> Wisdom Box</h1>


  

  <div class="machine">
    <button class="button" type="button " onclick="myFunction()">Wisdom</button>


    <p class="quoteboxtext  quotetxt qtxt"> Quote </p> <!-- Here the class quoteTxt calls ID of JS function var-->

    <p class="quoteboxtext  quotename txt"> Author</p>

    <a href="https://twitter.com/share" class="twitter-share-button" data-size="large">
  Tweet</a>

    <script>
      !function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');
    </script>
  </div>
</div>
</body>
            
          
!
            
               body {
  background-color:  #630;
}
.background {
  background-color: #630;
 }

.heading {
  color: #000;
  text-decoration: underline;
  font-size: 50px;
  font-weight: bold;
  text-align: center;
}
.quoteboxheading {
  text-align: center;
  text-decoration: underline;
  font-weight:bold;
  color:black;
}

.machine {
  background-color: #91543e;
  align: center;
  border: 5px solid black;
}

.quoteboxtext {
  text-align: center;
  font-size:21px;
  
}


.button {
  background-color: #632;
  border: #111 solid 2px;
  color: black;
  padding: 15px 32px;
  text-align: center;
  border-radius: 6px;
  font-weight:bold;
  display: inline-block;
  font-size: 16px;
  padding-bottom: 10px;
  margin-left: 44%;
}

.txt {
  color: #000;
  font-style: italic;
}

.qtxt {
  color: #000;
  font-style: ;
}
            
          
!
            
              var arr = [
  ["There is a natural aristocracy among men. The grounds of this are virtue and talents.", " Thomas Jefferson (1743-1826)"],
  ["All our words from loose using have lost their edge.",
    "Ernest Hemingway (1898-1961)"
  ],
  ["God couldn't be everywhere, so he created mothers.",
    "Jewish proverb"
  ],
  ["Be not afraid of going slowly, be afraid only of standing still.",
    "Chinese proverb"
  ],
  ["Learn from yesterday, live for today, hope for tomorrow.",
    "Unknown Source"
  ],
  ["In teaching others we teach ourselves.",
    "Proverb"
  ],
  ["Happiness will never come to those who fail to appreciate what they already have.",
    "Unknown Source"
  ],
  ["Without His love I can do nothing, with His love there is nothing I cannot do.",
    "Unknown Source"
  ],
  ["The true sign of intelligence is not knowledge but imagination.",
    "Albert Einstein (1879-1955)"
  ],
  ["I have not failed. I've just found 10,000 ways that won't work.",
    "Thomas Alva Edison (1847-1931)"
  ],
  ["Either write something worth reading or do something worth writing.",
    "Benjamin Franklin (1706-1790)"
  ],
  ["The way to love anything is to realize that it might be lost.",
    "Gilbert Keith Chesterton (1874-1936)"
  ],
  ["Happiness is when what you think, what you say, and what you do are in harmony.",
    "Mahatma Gandhi (1869-1948)"
  ],
  ["One cannot think well, love well, sleep well, if one has not dined well.",
    "Virginia Woolf (1882-1941) "
  ],
  ["To improve is to change; to be perfect is to change often.",
    "Winston Churchill (1874-1965)"
  ]
];

function myFunction() {

  var name = "";
  var quote = "";

  for (i = Math.floor((Math.random() * 15) + 1); i < arr.length; i++) {//I starts at random position in array.
                                            //It picks 1 subarray and element 1 and 2 are taken
    quote = arr[i][0]; //labelled quote and name
    name = arr[i][1];
   
$("p.quotetxt").html(quote); //They are then given $ Ids which can be called by html class
    $("p.quotename").html(name);
    return;
  }
}



    

            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.

Console