Help debug a little plugin

Help debug a little plugin

This plugin is to make an element the same size with other one.

  1. (function($){
  2.     $.fn.fitSize = function(options){
  3.         var defaults = {
  4.             target_object:'',
  5.             fitWidth:true,
  6.             fitHeight: true
  7.         },
  8.         settings = $.extend({},defaults, options);
  9.        
  10.         return this.each(function(){
  11.            
  12.             var $this=$(this);
  13.             if(settings.fitWidth == true) {
  14.                 var fake_width = $this.outerWidth(true)-$this.width();
  15.                 $this.width(settings.target_object.width()-fake_width);
  16.             }
  17.             if(settings.fitheight == true){
  18.                 var fake_height = $this.outerHeight(true)-$this.height();
  19.                 $this.height(settings.target_object.height()-fake_height);
  20.             }
  21.         });
  22.     }
  23. })(jQuery);
Run
  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <style>
  5. #a{width:400px; height:600px; background:#66C}
  6. #b{background:#FC3}
  7. </style>
  8. <script>
  9. $(function(){
  10.     $('#b').fitSize($('#a'));//make b the same size with a
  11. });
  12. </script>
  13. </head>
  14. <body>
  15. <div id="a"></div>
  16. <div id="b"></div>
  17. </body>
  18. </html>

Firebug error: settings.target_object.width() function is not defined.