I tried and I didn't found any problems, but I changed the tag with the tag
This is my piece of code
In the section head
<link type="text/css" href="css/ui-lightness/jquery-ui-1.8.6.custom.css" rel="Stylesheet" />
<script type="text/javascript" src="js/jquery-1.4.3.js"></script>
<script type="text/javascript" src="js/jquery-ui-1.8.6.custom.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('#fooBtn').bind('click', function(event) {
addRow();
});
});
</script>
input[type=button].delete {
color: red
` }
function addRow is your code
function addRow(){
var tdata = "<tr>";
tdata += "<td align=\"right\">my data</td>";
tdata += "<td align=\"left\">";
tdata += "<input type=\"button\" class=\"delete\" value=\"delete\">";
tdata += "</td>";
tdata += "</tr>";
jQuery('#mytable > tbody:last').append(tdata);
}
In the section body
<table id="mytable">
<tr>
<td align="right">
my data
</td>
<td align="left">
<input type="button" class="delete" value="delete"></input>
</td>
</tr>
</table>
<input type="button" id="fooBtn" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only delete" value="Add Row" />
Try and give me a feedback
D.
For handler click events you have to change this piece of code
var tdataElement = jQuery(tdata);
var bt = tdataElement.find(":button");
bt.button();
bt.click(function() {
alert('Handler for .click() called.');
});
jQuery('#mytable > tbody:last').append(tdataElement);