How to add row to table using jquery?

Adding dynamically row to table using jquery is very simple . Row that is added by clicking a button and every row has its unique random id. Here is some code that creates random id and added row to table.

  function addRow()
var col1=$(“[name=col1]”).val();
var col2=$(“[name=col2]”).val();
var col3=$(“[name=col3]”).val();

var row=”<tr id=”+generateID()+”><td>”+col1+”</td>”;

if($(‘#col1:contains(“‘+col1+'”)’).length <= 0)
$(“#weapRow”).append(row).fadeIn(‘slow’);  // weapRow is table name

function generateID()
var randLetter = String.fromCharCode(65 + Math.floor(Math.random() * 26));
var unique_id = randLetter +;
return randLetter+unique_id;

Leave a Reply

Your email address will not be published. Required fields are marked *