$(document).ready(function() {
  $('button.alert').click(function() {
    alert('this is an alert message');
  });
  
  
  $('#create-button').click(function() {
    if ( $('button.alert').length < 2) {
      $('<button class="alert">Not another alert</button>').insertAfter(this);
    }
    return false;
  });
  
  
  $('#list1 li.special button').click(function() {
    var $newLi = $('<li class="special">special and new <button>I am new</button></li>');
    $(this).parent().after($newLi);
  });
  
  $('#list2').click(function(gummy) {
    var $newLi = $('<li class="special">special and new <button>I am new</button></li>');
    var $tgt = $(gummy.target);
    if ($tgt.is('button')) {
      $tgt.parent().after($newLi);
    }

    // next 2 lines show that you've clicked on the ul
    bgc = $(this).css('backgroundColor');
    $(this).css({backgroundColor: bgc == '#ffcccc' || bgc == 'rgb(255, 204, 204)' ? '#ccccff' : '#ffcccc'});  
  });

  $('#list3 li.special button').click(function() {
    var $parent = $(this).parent();
    $parent.clone(true).append(' I\'m a clone!').insertAfter($parent);
  });

  function addListItem() {
    $('#list4 li.special button').unbind('click').click(function() {
      var $newLi = $('<li class="special">special and new <button>I am new</button></li>');
      $(this).parent().after($newLi);
      addListItem();
    });
  }
  addListItem();
  
});