<script>
$(document).ready(function(){
var i = <?=$iMaxId?>;
var c = 0;
$('#addphone').click(function(){
i += 1;
c += 1;
var sTag = "<div class='trow' id='Phone"+i+"'><div>Phone No. </div><div><input type='text' name='sPhone[]' ><input type='button' value='delete' class='delete' id='"+i+"'></div></div>";
$('#imgfield').last().before(sTag);
});
$(".delete").click(function()
{
var iId = $(this).attr("id");;
$("#Phone" + iId).remove( );
});
});
</script>
This script is adding input fields flawlessly but is not able to remove them when clicked the delete button.