Skip to content

Instantly share code, notes, and snippets.

@Kaeleigh
Created January 7, 2018 23:49
Show Gist options
  • Save Kaeleigh/2f3b4a9fc140495e64f94c22bd820c0d to your computer and use it in GitHub Desktop.
Save Kaeleigh/2f3b4a9fc140495e64f94c22bd820c0d to your computer and use it in GitHub Desktop.
JS Bin // source http://jsbin.com/yarixoq
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<script src="https://code.jquery.com/jquery-3.0.0.js"></script>
</head>
<body>
<h1>My Awesome ToDo List</h1>
<ul id="todo-list">
<li class= one> </li>
<li> </li>
<li> </li>
</ul>
<script id="jsbin-javascript">
var todoListItems = [
{"title" : "Walk the dog"},
{"main" : "Clean the car"},
{"heading" : "Do the laundry"}
]
// Append each to do list item in the
// array to the un ordered list with
// the id of "todo-list".
// Use jQuery.
var addTodos = function() {
$.each(todoListItems, function( index, value ) {
$('#todo-list li:eq(0)').append(value.title);
$('#todo-list li:eq(1)').append(value.main);
$('#todo-list li:eq(2)').append(value.heading);
});
}
$(addTodos)
</script>
<script id="jsbin-source-javascript" type="text/javascript">var todoListItems = [
{"title" : "Walk the dog"},
{"main" : "Clean the car"},
{"heading" : "Do the laundry"}
]
// Append each to do list item in the
// array to the un ordered list with
// the id of "todo-list".
// Use jQuery.
var addTodos = function() {
$.each(todoListItems, function( index, value ) {
$('#todo-list li:eq(0)').append(value.title);
$('#todo-list li:eq(1)').append(value.main);
$('#todo-list li:eq(2)').append(value.heading);
});
}
$(addTodos)
</script></body>
</html>
var todoListItems = [
{"title" : "Walk the dog"},
{"main" : "Clean the car"},
{"heading" : "Do the laundry"}
]
// Append each to do list item in the
// array to the un ordered list with
// the id of "todo-list".
// Use jQuery.
var addTodos = function() {
$.each(todoListItems, function( index, value ) {
$('#todo-list li:eq(0)').append(value.title);
$('#todo-list li:eq(1)').append(value.main);
$('#todo-list li:eq(2)').append(value.heading);
});
}
$(addTodos)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment