Extending using jQuery

JQuery.fn.extend() method actually extends the jQuery prototype ($.fn) object to provide new methods which can be chained to JQuery. For e.g- After searching the elemnts using Jquery,  I want to call my custom methods that too with chaining, in that case I will extend it.

  1. <label>  
  2.         <input type="checkbox" name="foo" />  
  3.         Foo</label>  
  4.     <label>  
  5.         <input type="checkbox" name="bar" />  
  6.         Bar</label>  
  7.     <script type="text/javascript">  
  8.         jQuery.fn.extend({  
  9.             check: function () {  
  10.                 return this.each(function () {  
  11.                     this.checked = true;  
  12.                     alert('f');  
  13.                 });  
  14.             },  
  15.             uncheck: function () {  
  16.                 return this.each(function () {  
  17.                     this.checked = false;  
  18.                 });  
  19.             }  
  20.         });  
  21.   
  22.         $("input[type='checkbox']").check();  
  23.   
  24.     </script>  

Hope this helps you.