Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource


Babel includes JSX processing.

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


Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.


Auto Save

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.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.



  <meta charset="UTF-8">
  <title>Fridge Magnets</title>
  body {
      background: url( 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=""></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