My version plays nice if you have other libraries that take up the $
namespace (ie, prototype framework)

On Dec 21, 7:50 am, "Lay András" <lays...@gmail.com> wrote:
> Hello!
>
>
>
> On Sun, Dec 21, 2008 at 3:09 PM, Kean <shenan...@gmail.com> wrote:
> > Well blank() was not created in jQuery.
>
> > You can create a new function for jQuery like this.
>
> > (function($){
> >  $.fn.blank = function(){
> >    return $.trim(this[0]).length == 0;
> >  }
> > })(jQuery)
>
> > <input id="one" value="sadf" />
> > <input id="two" value="  " />
>
> > $('#one').blank(); // return false
> > $('#two').blank(); // return true
>
> > haven't tested the code but should be pointing you to the right
> > direction.
>
> Thank you, this example point me to the right direction. I've made
> minor changes and your code works:
>
> (function($) {
>         $.fn.blank=function() {
>                 return $.trim($(this).val()).length==0;
>         }
>
> })(jQuery);
>
> But this works too:
>
> $.fn.blank=function() {
>         return $.trim($(this).val()).length==0;
>
> };
>
> What's the difference between two versions?
>
> Lay

Reply via email to