$().relCopy();relCopy, short for rel copy, is a jQuery plugin that copies any DOM element, and its children, targeted by an action link's rel tag. It is typically used in forms to copy the file upload fields for multiple file uploads. It can also be customized for any purpose that requires multiple copies of fields with limits and other features.
Call $(selector).relCopy(options) on an element with a jQuery type selector defined in the attribute rel tag. This defines the DOM element to copy.
In the example below, .phone in rel=".phone"is the selector jQuery will use to search the DOM and copy. Note: This can be any jQuery selector like #phone.
$('a.copy').relCopy({limit: 5}); // <a href="example.com" class="copy" rel=".phone">Copy Phone</a>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script> <script type="text/javascript" src="jquery/relCopy.jquery.js"></script>
$().relCopy() on elements when DOM is ready
<script>
$(function(){
$('a.copy').relCopy();
});
</script>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Rel Copy Example</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript" src="jquery/relCopy.jquery.js"></script>
<script>
$(function(){
$('a.copy').relCopy();
});
</script>
</head>
<body>
<p><a href="#" class="copy" rel=".phone">Copy Phone</a></p>
<p class="phone"><label>Phone Number: <input type="text" /></label></p>
</body>
</html>
$('a.copy').relCopy();
var removeLink = ' <a class="remove" href="#" onclick="$(this).parent().slideUp(function(){ $(this).remove() }); return false">remove</a>';
$('a.copy').relCopy({limit: 3, append: removeLink});
var removeLink = ' <a class="remove" href="#" onclick="$(this).parent().remove(); return false">remove</a>';
$('a.copy').relCopy({limit: 5, append: removeLink});
clearInputs.clearInputs.append option.