I just wrote my first jQuery (test) plugin... This was my guide: <http://www.learningjquery.com/2007/10/a-plugin-development-pattern>
Questions: ========== 1. My plugin only takes one argument/option, and that is a target dom element. For example: $('#div').myFunction({ target: '#targ' }); When it comes to the defaults, what is the best way to handle the default value for an unknown target object? This is what I am currently doing: $.fn.myFunction.defaults = { target: '' }; But, I guess I am wondering what the best way to handle javascript error checking for required options? In other words, how you do you gracefully exit your plugin if the "target" was not passed into the plugin as an option? Or, what if the target div does not exist? Tips? :) 2. When calling my plugin: $('#div').myFunction({ target: '#targ' }); If the only option is "target", can I do something like this instead: $('#div').myFunction('#targ'); 3. Because "#targ" is a required argument, should I handle it differently than your normal "options" object? ========== I hope those questions make sense. A billion thanks in advance for the help! Cheers, Micky