Created
December 3, 2009 04:42
-
-
Save levicole/247891 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // usage: $("#element").copyFields("#to", "#from") | |
| (function($) { | |
| $.fn.copyFields = function(to, from) { | |
| // find all the inputs in to | |
| var to = $(to + " input"); | |
| // find all the inputs in from | |
| var from = $(from + " input"); | |
| // when you click on the element | |
| $(this).click(function() { | |
| //loop through all the from inputs and put the value in the to input... | |
| for (var i = 0; i < from.length; i++) { | |
| to[i].value = from[i].value | |
| }; | |
| }); | |
| }; | |
| })(jQuery) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment