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.

Quick-add: + add another resource

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.

Quick-add: + add another resource

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.

            
              <div id="container">
	<h1>To-Do List <i class="fa fa-plus"></i></h1>
	<input type="text" placeholder="Add New Todo">
	<ul>
	</ul>
</div>
            
          
!
            
              /* https://uigradients.com/#Martini */
body {
  background: #FDFC47;  /* fallback for old browsers */
  background: -webkit-linear-gradient(to right, #24FE41, #FDFC47);  /* Chrome 10-25, Safari 5.1-6 */
  background: linear-gradient(to right, #24FE41, #FDFC47); /* W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+ */
}

#container {
	width: 460px;
	margin: 100px auto;
	background: #f7f7f7;
	box-shadow: 0 0 3px rgba(0,0,0, 0.1);
}

h1 {
	background: #2980b9;
	color: white;
	margin: 0;
	padding: 10px 20px;
	text-transform: uppercase;
	font-size: 24px;
	font-weight: normal;
}

input {
	font-size: 18px;
	color: #2980b9;
	background-color: #f7f7f7;
	width: 100%;
	padding: 13px 13px 13px 20px;
	box-sizing: border-box;
	border: 3px solid rgba(0,0,0,0);
}

ul {
	list-style: none;
	margin: 0;
	padding: 0;
}

li {
	background: #fff;
	height: 40px;
	line-height: 40px;
	color: #666;
}

.fa-plus {
	float: right;
}

li:nth-child(2n){
	background: #f7f7f7;
}

span {
	background: #e74c3c;
	height: 40px;
	margin-right: 20px;
	text-align: center;
	color: white;
	width: 0;
	display: inline-block;
	transition: 0.2s linear;
	opacity: 0;
}

li:hover span {
	width: 40px;
	opacity: 1.0;
}

input:focus{
	background: #fff;
	border: 3px solid #2980b9;
	outline: none;
}

.completed {
	color: gray;
	text-decoration: line-through;
}
            
          
!
            
              'use strict';

// ulを親要素に持つliに対してクラスをスイッチ
$("ul").on("click", "li", function(){
	$(this).toggleClass("completed");
});


// ulを親要素に持つspan要素に対してコールバック
// iconをクリックした時に、親要素をfadeOut+elementを削除
$("ul").on("click", "span", function(event){
	$(this).parent().fadeOut(500,function(){
		$(this).remove();
	});
	event.stopPropagation();
});


// Enterを押したときの要素の追加処理
$("input[type='text']").keypress(function(event){
	if(event.which === 13){
		var todoText = $(this).val();
    // 変数に格納した後はinputの中身は空にする
		$(this).val("");
		$("ul").append("<li><span><i class='fa fa-trash'></i></span> " + todoText + "</li>")
	}
});

// 入力欄切り替える処理
$(".fa-plus").click(function(){
	$("input[type='text'").fadeToggle()
});
            
          
!
999px
Loading ..................

Console