I have a datatable. I want to simply add a row or delete dynamically. For deleting the row we simply use fnRowDelete() function which makes all task easy.
<table>
<tr>
<td><p>sr no</p></td>
<td><div>First name</div></td>
<td><div>Last name</div></td>
</tr>
</table>
However adding a new row using fnAddData(1,"john","doe") does the job but it will add a row by adding this data directly inside the tag with no custom html.
<table>
<tr>
<td>1</td>
<td>john</td>
<td>doe</td>
</tr>
</table>
Here i want to add this row with its html tags as well. if we pass html as string in the function fnAddData() to get required output, we will not be able to make both javascript and html code separate (use of template).
Is there any way how i can keep both javascript and html code in different file and still be able to add a row in required format.
Required sample output:-
<table>
<tr>
<td><p>1</p></td>
<td><div>john</div></td>
<td><div>doe</div></td>
</tr>
</table>