Skip to content

Instantly share code, notes, and snippets.

View schatekar's full-sized avatar

Suhas Chatekar schatekar

View GitHub Profile
@schatekar
schatekar / todo-1.js
Created March 18, 2012 20:45
Example source for "writing better javascript, part - 1"
$(document).ready(function () {
// Returns formatted HTML for a todo item
function getToDoHtml(todo) {
return '<li><span class="todo">' + todo + '</span><a class="edit">Edit</a><a class="remove">Remove</a></li>';
}
// When Add button is clicked, appends the todo item from the textbox to the list of todo items
$('input[type="submit"].add-todo').click(function () {
var todo = $('input[type="text"].add-todo').val();