jquery add and remove elements

jquery add and remove elements

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>jQuery Test on - phpsimpleqa.blogspot.com</title>
<script type="text/javascript"   src="http://jobanjohn.googlepages.com/jquery.js"></script>
<script type="text/javascript">
function addNewToPhpqa() {
         var id = $('#idVal').val();
         id++;
          // set a maximum value for elements
          if(id<10){
                   $("#phpsimpleqaToAppend").append("<p id='count" + id + "'><label for='txt" + id + "'>Field " + id + "&nbsp;&nbsp;<input type='text' size='20' name='txtName[]' id='txtName" + id + "'>&nbsp;&nbsp<a href='javascript:void(0);' onClick='removeThisFromPhpsimpleqa("+ id +");'>Remove this</a><p>");
          }else{
          alert("you have reached maximum Thanks phpsimpleqa.blogspot.com");
          }
          $('#idVal').val(id);
}

function removeThisFromPhpqa(id) {
         $("#count"+id).hide(1000);
         // or u can use
         //$("#count"+id).remove();
}
</script>

<body>
<p><a href="javascript:void(0);" onClick="addNewToPhpqa();">Add More</a></p>
<form action="#" method="get" id="phpqa">
<input type="hidden" id="idVal" value="1">
<div id="phpsimpleqaToAppend">
<p id='count1'>
<label for="txt1">
Field 1
&nbsp;&nbsp;
<input size="20" name="txtName[]" id="txtName1" type="text">
&nbsp;&nbsp;
<a href="javascript:void(0);"
onclick="removeThisFromPhpsimpleqa(1);">Remove this</a>
</label>
</p>
</div>
<label ></label>
<p><input type="submit" value="Submit" name="submit">
<input type="reset" value="Reset" name="reset"></p>
</span>
</form>
</body>
</html>