javascript - How to add border style to a table whose rows are added dynamically in jquery? -
i trying add css table dynamically created on button click. function called on click event has below qjuery part creates dynamic rows
$("#employedetail").append('<tr class="hide1" id="row'+empcurrentindex+'">' +'<td >'+employername[empcurrentindex]+'</td>' +'<td >'+empmobileno[empcurrentindex]+'</td>' +'<td >'+emplocation[empcurrentindex]+'</td>' +'<td >'+emptotnomonth[empcurrentindex]+'</td>' +'<td><button class="btn" name="delete" value="delete" onclick="return deleteemprow('+empcurrentindex+');">delete</button></td>' +'<td><button class="btn" name="edit" value="edit" onclick="return editemprow('+empcurrentindex+');">edit</button></td>' +'</td></tr>').addclass('newrow');
button under table tag calls javascript function create dynamic rows. want have border created rows. tried .addclass('newrow') where
.newrow{ border:5px; border-color:red; }
but doesn't seem apply. appreciated.
thanks
your problem append()
not return row, have appended to. there several ways around issue, simplest in instance put class in class attribute create row...
$("#employedetail").append('<tr class="hide1 newrow" id="row'+empcurrentindex+'">' +'<td >'+employername[empcurrentindex]+'</td>' +'<td >'+empmobileno[empcurrentindex]+'</td>' +'<td >'+emplocation[empcurrentindex]+'</td>' +'<td >'+emptotnomonth[empcurrentindex]+'</td>' +'<td><button class="btn" name="delete" value="delete" onclick="return deleteemprow('+empcurrentindex+');">delete</button></td>' +'<td><button class="btn" name="edit" value="edit" onclick="return editemprow('+empcurrentindex+');">edit</button></td>' +'</td></tr>');
Comments
Post a Comment