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


Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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


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.

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.


                <input type='text' id='new-todo'><button id='new-todo-button'>+</button>
<div id="todo-list">


<!-- Not for displaying. For JS to use -->
<div id="template">
  <div class="todo-item">
      <input type='checkbox'>      
      <span class="content">Todo content goes here.</span>


                /* Hide the template */
#template {
  display: none;

/* Todo List */
#todo-list {
.todo-item {
.todo-item input:checked ~ span,
.todo-item.done {
  color: LIGHTGRAY;
  text-decoration: strike;

/* Not related */
body {
  padding: 50px;
  font-size: 16pt;


                // NOTE: this is 
// data
var todos = [];

// saving and loading the list, locally.
function saveTodos() {
  localStorage.setItem('todos', JSON.stringify(todos));

function loadTodos() {
  var savedData = localStorage.getItem('todos');
  if (savedData !== null && savedData !== undefined) {
    return JSON.parse(savedData);
  return [];

// view rendering
function createTodoListFromData() {
  // empty current list

  // loop the data
  $.each(todos, function() {
    var todo = this;
    var clone = $('#template').find('.todo-item').clone();

    if (todo.done) {
      clone.find('input[type=checkbox]').prop('checked', true);


function addTodoFromInput() {
  var newTodo = $('#new-todo').val();
    done: false,
    content: newTodo,

  // save the todo list

function fetchTodosFromServer() {
  // fetch the todo from server
  // server url:

  var url = '';

  // fetch the data from the URL.
  $.getJSON(url, function(data) {
    // log the data to console so we can inspect the data structune before using it.
    console.log("From server: ", data);

    // assign to the global todos data.
    todos = data.todos;

    // refresh the list view

// logic that runs at the beginning

// load the todos at the beginninng.
todos = loadTodos();

// if there is no any saved data, we fetch a sample data from server
if (todos.length > 0) {
} else {

// handle the add todo 
$('#new-todo').keyup(function(event) {
  var keycode = event.keyCode;
  if (keycode === 13) {