<script>
var a = 2;
var bb=0;
function add() {
a++;
var newRow = $("#templateTr").html();
$("#templateTr").find(".spth").html(a);
$(".aaa").before(newRow);
$(".numberspan").html((a));
bb = a + 1;
$("#templateTrMade").find(".madespth").html(bb);
}
function remove() {
var index = $(".aaa").index();
if (index > 5) {
$("table").find("tr").eq(index).remove();
a--;
$("#templateTr").find(".spth").html(a);
$(".numberspan").html((a));
bb = a + 1;
$("#templateTrMade").find(".madespth").html(bb);
}
}
</script>