Confused about adding multiple td's to tr using jQuery
Posted
by
Jason
on Stack Overflow
See other posts from Stack Overflow
or by Jason
Published on 2012-02-18T22:29:30Z
Indexed on
2013/11/03
15:54 UTC
Read the original article
Hit count: 216
JavaScript
|jQuery
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]
© Stack Overflow or respective owner