Why do we have to create whole div into jQuery?


#1

$(document).ready(function(){
$('#button').click(function(){
var toAdd = $('input[name=checkListItem]').val();
$('.list').append('

' + toAdd + '
')
});
});

Why do we have to create a new div in // $('.list').append('

' + toAdd + '
') //
it works great but I don't really understand how it works.

#2

Hi Ayaz,

It's to keep the HTML document structure neat and tidy, and to allow removal of list items :)