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.

+ 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.


  <meta charset="UTF-8">
  <title>Fridge Magnets</title>
  body {
      background: url(https://res.cloudinary.com/thefinleycode/image/fetch/https://res.cloudinary.com/thefinleycode/image/upload/v1471283486/fridge_cxyly4.png) no-repeat;
  .letter {
      width: 30px;
      height: 30px;
      border-style: solid;
      padding: 2px;
      float: left;
      margin: 2px;
  .letter-button-color {
      color: darkcyan;
  .fridge-color {
      color: orange;
  #display {
      margin-top: 78px;
      height: 500px;
      width: 220px;
      margin-left: 60px;
  #buttons {
      padding-top: 60px;
  #clear {
      margin-left: 20px;
      font-size: 25px;
      color: black;
      border-style: solid;
      width: 100px;

  <div id="display"></div>
  <div id="buttons"></div>
  <button id="clear">clear</button>
  <script type="text/javascript" src="https://code.jquery.com/jquery-2.2.0.min.js"></script>


              $(document).ready(function() {
  //we store all the letters and underscore inside of an array called letters
  var letters = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "_"];

  step 1: loop over the letters
  	step 2: inside the loop
  		* make a variable named b
  			* set it equal to a button with
  				- the following classes: letter-button letter letter-button-color
  				- a data-let attribute set equal to letters[i]
  				- text of letters[i]
  		* step 3: append b to the div with an id of buttons

  // For step 1: Solution 1= 

  for (var i = 0; i < letters.length; i++) {
    var b = $('<button>');
    b.addClass('letter letter-button-color letter-button');
    b.attr('data-let', letters[i]);




  $('.letter-button').on('click', function() {
    var fridgeMagnet = $('<div>');
    fridgeMagnet.addClass('letter fridge-color').text($(this).data('let'));
    	Step 4:

    	* inside this anonymous function that gets passed to the click event
    		* create a variable called fridgeMagnet
    			* set the variable equal to a new div
    				* with the following classes: letter fridge-color
    				* chain this on:

    /* Step 5: append the fridgeMagnet variable to the element with an id of display */


  //Step 6: on the element with an id of clear, attach an on click function
  $('#clear').on('click', function() {

    	Step 7: inside this anonymous function that gets passed to the click event
    		* use the empty() function on the element with an id of display



🕑 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.
Loading ..................