Dear All,
I have a code as below. Each time I press the add button it will create a new row. What I notice is that if I comment this line prot.attr("class", "") it does not work why must I make the class empty then only it works. Secondly when I add a new row it copies the data from the first row always. So I added this line prot.find("#col4").attr("value", ""); but it does not work either too. Any help please.


HTML Code:
<html>
	<head>
		<script src="http://code.jquery.com/jquery-1.5.1.min.js"></script>
		<script>
		$(document).ready(function() {
			var id = 0;
			
			// Add button functionality
			$("table.dynatable button.add").click(function() {
				id++;
				var master = $(this).parents("table.dynatable");
				
				// Get a new row based on the prototype row
				var prot = master.find(".prototype").clone();
				prot.attr("class", "")
				prot.find(".id").attr("value", id);
				//prot.find("#col4").attr("value", "");				
				master.find("tbody").append(prot);
			});
			
			// Remove button functionality
			$("table.dynatable button.remove").live("click", function() {
				$(this).parents("tr").remove();
				
			});
		});
		</script>
		<style>
			.dynatable {
				border: solid 1px #000; 
				border-collapse: collapse;
			}
			.dynatable th,
			.dynatable td {
				background-color:#ccc; 
				font-size:14px;
				font-color:#ffffff;
				font-family:Calibri;
			}
			.dynatable .prototype {
				
			}
		</style>
	</head>
	<body>
		<form action="<?=$_SERVER['PHP_SELF']?>" method="post" name="form1" enctype="multipart/form-data" id=form1 >
		<table class="dynatable">
			<thead>
				<tr>
					<th>ID</th>
					<th>Name</th>
					<th>Col 3</th>
					<th>Col 4</th>
					<th><button class="add">Add</button></th>
				</tr>
			</thead>
			<tbody>
				<tr class="prototype">
					<td><input type="text" name="id[]" value="0" class="id" /></td>
					<td><input type="text" name="name[]" value="" /></td>
					<td><input type="text" name="years" value="" /></td>
					<td><input type="text" name="col4[]" value="" /></td>
					<td><button class="remove">Remove</button>
				</tr>
				
		</table>
		<input class="buttons" type="Submit" name="Submit" value="Submit">
	</form>
	</body>
</html>