views:

32

answers:

1

I want to add an <img> in a <td>

$myRow = $("<tr></tr>");
$myRow.append("<td>$('<img/>').attr({ src: 'xx' })</td>"),

as expected it's considering it as a string. How to format this using jQuery, so that it creates an <img>?

+4  A: 
$myRow = $("<tr></tr>");
$('<td></td>').appendTo($myRow)
    .append($('<img/>')
        .attr({ src: 'xx' })
    ),
    // ...
);
strager