<script>
function insert(button){
$(button).appendTo($('td.toinsert'));
}
</script>
<table>
<tr>
<td class="toinsert">inside cell</td>
</tr>
</table>
<input type="button" onclick="insert(this)" value="button"/>
Also to create a button and add an event to it
<script>
$(function(){
$('<input></input>').attr({'type': 'button'}).val("button").click(function(){
alert('hello');
}).appendTo($('td.toinsert'));
});
</script>
<table>
<tr>
<td class="toinsert">inside cell</td>
</tr>
</table>
source
share