I have a table on which the user can select a row. I've made some CSS
to highlight the selected row. The user can add rows to the original table. The probelm is that the added rows are not highlighted when selected.
HTML PART :
<table class="table_to_fill" id="table_id">
<thead>
<tr>
<th> title 1 </th>
<th> title 2 </th>
</tr>
</thead>
<tbody>
<tr>
<td>old row 1</td>
<td>old row 1</td>
</tr>
<tr>
<td>old row 2</td>
<td>old row 1</td>
</tr>
</tbody>
</table>
CSS :
.table_to_fill tr:hover, .table_to_fill tr.selected {
background-color: #1E90FF;
color : #fff;
font-weight : bold;}
Javascript :
$(".table_to_fill tr").click(function(){
$(this).addClass("selected").siblings().removeClass("selected");
});
//to add rows
$("#add_row_button").click(function(){
$('#table_id tr:last').after('<tr><td>new row</td><td>new row</td></tr>');
});
So what I'm doing wrong ? Thanks for any help.