Need some help with my jQuery input styler
<p>Here's the, stripped down, code:</p>

<pre><code>$(document).ready(function()
{
   var $input = $('input[type="checkbox"]');

   $input.wrap('&lt;div class="stylecheck-container" style="display: inline" /&gt;').addClass('stylecheck').hide();
   $container = $input.parent('div.stylecheck-container');

   if ($container.parent('label').length &gt; 0)
   {
      $container.append($container.parent('label').text() + ' ');
      $container.parent('label').replaceWith($container);
   }

   $input.change(function()
   {
      alert(1);
   });

   $container.click(function()
   {
      if ($input.is(':checkbox'))
      {
         if ($input.is(':checked'))
            $input.attr('checked', true);
         else
            $input.attr('checked', false);
      }
   });
}); 
</code></pre>

<p>The problem I'm having is that when I try and remove the parent label, the change no longer gets detected.</p>

<p>If I comment out the line 6 if statement, it works fine.</p>

<p>What's the deal?</p>
