Thanks all. I did have a think about which way around I wanted it to
work. Thinking about what will be returned is also handy.

I can see me wrting more plugins now.

Thanks again.

Adrian

On Oct 30, 2:51 am, Dave Methvin <[EMAIL PROTECTED]> wrote:
> > $(ELEMENTS_TO_CHANGE).syncValue(ELEMENT_I_WISH_TO_COPY).show();
> > That way your focus is on the changing element.
>
> I tend to agree; if that's what you want then it's pretty short
> already.
>
> $(syncElements).val(formatter(elementToCopy.val())).show();
>
> The other way around isn't a lot longer but it's uglier.
>
> $(elementToCopy).each(function(){$(syncElements).val(formatter($
> (this).val())))}).show();
>
> So the plugin could just encapsulate the ugliness:
>
>  jQuery.fn.syncValue = function(syncElements, formatter) {
>    return this.each(function(){
>       $(syncElements).val(
>          (formatter || function(x){return x}}($(this).val()))
>       );
>    });
>
> };
>
> $(elementToCopy).syncValue(syncElements, formatter).show();

Reply via email to