Confused about adding multiple td's to tr using jQuery
- by Jason
So I have the following code:
<script type="text/javascript">
$(document).ready(
function () {
$("#txt").click(function () {
var $TableRow = $('<tr></tr>');
var $TableData = $('<td></td>');
var $TableData2 = $('<td></td>');
// Works
$("#tblControls").append(
$TableRow.html(
$TableData.text("Test, Hello World3")
)
);
</script>
<div style="display: inline">
<input type="button" id="txt" value="Add TextBox" style="" />
</div>
<br/>
<table id="tblControls" width="100%">
</table>
But why does this not add two td's to the tr?
$("#tblControls").append(
$TableRow.html(
$TableData.text("Test, Hello World3")
+
$TableData2.text("Test, Hello World4")
)
);
What I get is this:
[object Object][object Object]