Summary: I have a template which contains two add buttons and two tables. When user clicks add button rows should append to the respective table. Example:
<div class="reports">
<div class="panel">
<table class="A">
<thead>
<td>A</td>
<td>B</td>
<td>C</td>
<td>D</td>
<td>E</td>
<td>F</td>
</thead>
<tbody></tbody>
</table>
</div>
<button class="add" type="button">Add</button>
</div>
and jquery is
$('.reports').on('click','.add',function(){
var path = $(this).parents('.reports').find(.A tbody);
$(
'<tr>'+
'<td class="remove-row" role="button" aria-label="Remove Region"></td>'+
'<td>'+value1+'</td>'+
'<td><button>'+value2+'</button></td>'+
'<td>'+value3+'</td>'+
'<td>'+value4+'</td>'+
'<td class="ordering" aria-label="Re-order"></td>'+
'</tr>'
).appendTo(path);
});
I want to append first two columns and do something with the value2 and append value3,value4,lastcolumn. example:
$('.reports').on('click','.add',function(){
var path = $(this).parents('.reports').find('.A tbody');
$('<tr>'+'<td class="remove-row" role="button" aria-label="Remove Region"></td>'+
'<td>'+value1+'</td>').appendTo(path to first two columns);
$('<td><button>'+value2+'</button></td>').appendTo(path to third column);
$('<td>'+value3+'</td>'+'<td>'+value4+'</td>'+
'<td class="ordering" aria-label="Re-order"></td>'+'</tr>').appendTo(path to last 3 columns);
});
I looking for the logic here.