我有html,我需要动态地在表中追加一行,我还需要在append div类中捕获click事件。如何实现这一点?
JavaScript的:
$(document).ready(function() {
$("#click").click(function() {
$('table').prepend('<tr> <td>something3</td> <td> <a><div class="s"> s </a> </td></tr>');
});
$(".s").click(function() {
alert("Ok");
});
});
HTML:
<input type="button" id="click" value="click"/>
<table width='100%'>
<tr><td>something</td><td>else here</td></tr>
<tr><td>something2</td><td>else here2</td></tr>
<tr><td>something3</td><td>else here3</td></tr>
</table>