> $(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