title: Writing a new jQuery plugin
body: <pre><code>&lt;table class="data" border="1"&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
          &lt;/tr&gt;
              &lt;td&gt;&lt;input type="checkbox" /&gt;&lt;/td&gt;
  
          &lt;tr&gt;
              &lt;td&gt;&lt;input type="checkbox" /&gt;&lt;/td&gt;
  
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;input type="checkbox" /&gt;&lt;/td&gt;
          &lt;/tr&gt;        
      &lt;/tbody&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>While iterating through each <code>tr</code> element, check whether the given <code>&lt;tr&gt;</code> element has a checked checkbox, if so add the new class. If not, remove it.</p>
  
  <pre><code>jQuery.fn.deleteMark = function() {
  
     this.each(function() {
          alert( $('input:checkbox',this) );
          if ($('checkbox',this).is(':checked')){
              $(this).addClass("delemarked");
          }
          else{
              $(this).removeClass("delemarked");
          }
     })
  };
  </code></pre>
  
  <p>Now I want to add a class to each <code>tr</code> that is checked:</p>
  
  <pre><code>function refresh(){
      $('.data tbody tr').each(function() {
          $(this).deleteMark();
      });        
  }
  </code></pre>
  
  <p>Sadly this doesn't work for me. I will be grateful for any help.</p>