클릭하면이 메서드가 호출되고 변수가 항상 2로 초기화됩니다. 좋은 습관이 아닙니다. 다음과 같이 할 수 있습니다 : function add_allowance() {
var click;
jQuery("#addrows").click(function(){
jQuery('#maintable tr:last').after('<tr class="tablechild"><td><select name="empallownacename" id="allowancename" class="select2_category form-control"><option value="none" selected="selected">-Select-</option></select></td><td><input type="text" name="empmount" value="" class="form-control" /></td><td><input type="text" name="empdescription" value="" class="form-control" /></td><td><a style="cursor: pointer;" value="Remove" class="minusbtn" id="remove"><i class="fa fa-trash-o"></i></a></td></tr>');
});
click=$('table tr).length; // It will count number of rows in the table and return integer value no of rows
}