Skip to content

Instantly share code, notes, and snippets.

@ahirschberg
Last active August 29, 2015 14:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ahirschberg/80624e9f4bbd83cd2335 to your computer and use it in GitHub Desktop.
Save ahirschberg/80624e9f4bbd83cd2335 to your computer and use it in GitHub Desktop.
Showing how javascript indentation can be kind of gross looking, especially when dynamically writing html
// try 1
books.forEach(function (book) {
$('<li/>')
.html(
$('<a>')
.attr('href', 'book.html')
.append(
$('<h2/>').text(book.title)
) // this click now applies to the <li>, not
).click(function () { // the <a>, which may be confusing or unclear
do_something(book);
}).appendTo('#book-list');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment