I have one interesting question.
I want to add rows to table using jquery, and after to make added row to respond to mouseover event, but code does not work.
The problem is that row is added as expected, but does not respond to mouseover event.
Any suggestions will be appreciated.
Urmas.
Code is following:
<head>
<style type="text/css">
.elem {
color: purple;
background-color: #d8da3d
}
</style>
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js">
</script>
</head>
<body>
<table id="table">
<thead>
<tr>
<th>Numbers</th>
<th>Letters</th>
<th>Symbols</th>
</tr>
</thead>
<tbody>
<tr>
<td class='elem'>111</td>
<td class='elem'>aaa</td>
<td class='elem'>@@@</td>
</tr>
<tr>
<td class='elem'>222</td>
<td class='elem'>bbb</td>
<td class='elem'>###</td>
</tr>
<tr>
<td class='elem'>888</td>
<td class='elem'>iii</td>
<td class='elem'>???</td>
</tr>
</tbody>
</table>
<input type = "button" id = "add" value = "add row" />
<script type="text/javascript">
$(".elem").mouseover(function() {
alert("over");
});
$("#add").click(function() {
$row_to_add="";
$row_to_add+="<tr>";
$row_to_add+="<td class='elem'>999</td>";
$row_to_add+="<td class='elem'>qqq</td>";
$row_to_add+="<td class='elem'>&&&</td>";
$row_to_add+="</tr>";
$("#table tr:last").after($row_to_add);
});
</script>
</body>