css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

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.

            
              <h1>To-Do List</h1>
<div class="container">
  <div class="row">
    <input type="text" class="col-xs-8 col-sm-9">
    <div class="input-buttons col-xs-4 col-sm-3">
      <a href="#" class="clear-text"><i class="fa fa-trash-o fa-2x"></i></a>
      <a href="#" class="add-todo"><i class="fa fa-plus fa-2x"></i></a>
    </div> <!-- div.input-buttons-->
  </div> <!-- div.row -->
  <div class="row">
    <div class="error">
      <a href="#"><i class="fa fa-times"></i></a>
      <p>We both know you should be doing something right now. Please enter a task.</p>
    </div> <!-- div.error -->
    <!-- Start to-do list -->
    <ul class="todo-list col-xs-12">
    </ul>
  </div> <!-- div.row -->
</div> <!-- div.container -->
            
          
!
            
              $dark-gray: #455a64;
$light-gray: #90a4ae;
$white: #eceff1;
$red: #ff5252;
$green: #69f0ae;
$white-border: 1px solid $white;

body {
  background: $dark-gray;
  color: $white;
  font: {
    family: 'Lato', sans-serif;
    weight: 300;
  }
}

h1 {
  font: 72px 'Oswald', Arial, sans-serif;
  margin: 50px 0;
  text-align: center;
}

.container {
  margin: 0 auto;
  width: 95%;
  @media (min-width: 600px) {
    width: 75%;
  }
  @media (min-width: 900px) {
    width: 65%;
  }
}

input {
  background: transparent;
  border: none {
    bottom: $white-border;
  }
  font-size: 24px;
  height: 50px;
  padding-bottom: 15px;
  &:focus {
    outline: 0;
  }
  @media (min-width: 900px) {
    font-size: 32px;
  }
}

.input-buttons {
  height: 50px;
  border-bottom: $white-border;
  padding: 0;
  i {
    padding: 0 12px;
    color: $white;
    float: right;
  }
  .fa-plus {
    border-right: $white-border;
  }
  @media (min-width: 600px) {
    .fa-trash-o:hover {
      color: $red;
    }
    .fa-plus:hover {
      color: #69f0ae;
    }
  }
}

.error {
  color: $red;
  display: none;
  font-size: 16px;
  margin-top: 20px;
  text-align: center;
  .fa-times{
    color: $white;
    padding: 5px 15px;
    float: right;
    &:hover {
      color: #fafafa;
    }
  }
  p {
    margin: 20px 0;
    @media (min-width: 600px ){
      font-size: 20px;
    }
  }
}

.todo-list{
  padding: 0;
  margin: 20px 0 50px;
  .todo {
    background: $white;
    border-bottom: 1px dotted $dark-gray;
    color: $dark-gray;
    font-size: 20px;
    list-style: none;
    padding: 20px 130px 20px 15px;
    position: relative;
    white-space: normal;
  }
}

span {
  position: absolute;
  top: 15px;
  right: 0;
  a {
    color: $dark-gray;
  }
  i{
    padding: 10px 15px;
  }
  .fa-check {
    border-right: 1px solid $dark-gray;
    &:hover {
      color: $green;
    }
  }
  .fa-trash-o:hover {
    color: $red;
  }
}

.complete {
  color: $light-gray;
  text-decoration: line-through;
  .check {
    color: $green;
  }
}




            
          
!
            
              $(function(){

	// Input gains focus on document ready
	//$('input').focus();

	// Define function to add tasks to list
	function addTodo(){
		if($('input').val().trim() == "") {
			// Show error message
			$('.error').fadeIn(200);
			} else {
			// Hide error message
			$('.error').hide();

			// Get input value
			var $todo = $('input').val(); 

			// Create new list item
			var $newListItem = $('<li class="todo">' + $todo + '<span>' + 
			'<a href="#" class="check">' + '<i class="fa fa-check fa-lg"></i>' + '</a>' +
			'<a href="#" class="delete-todo">' + '<i class="fa fa-trash-o fa-lg"></i>' + '</a>' + 
			'</span>' + '</li>');

			// Add list item to end of list
			var $addListItem = $('ul').append($newListItem);

			// Hide list item before fading it into view
			$newListItem.hide().fadeIn(500);

			// Refocus input box for next task
			$('input').val("").focus();
		}
	};

	// Clear error message when 'x' icon is clicked
	$('i.fa-times').on('click', function(){
		$('.error').hide();
	});

	// Call addTodo function on click
	$('.add-todo').on('click', addTodo);


	// Call addTodo function when enter key is pressed
	$(document).on('keypress', function(e){
		if(e.which == 13) {
			addTodo();
		}
	});
	

	// Clear typed text and refocus input box
	$('.clear-text').on('click', function(e) {
		e.preventDefault();
		$('input').val("").focus();
	});


	// Mark list item complete
	$(document).on('click', '.check', function(e){
		e.preventDefault();
		$(this).closest('li').toggleClass('complete');
	});


	// Fade list item and delete from DOM
	$(document).on('click', '.delete-todo' , function(e){
		e.preventDefault();
		$(this).closest('li').fadeOut(500, function(){
			$(this).remove();
		});
	});

});




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

Console