Jquery append add html?

#1

Hi Im trying to add above tbody or a table some content but for some reason doesn’t work when I add html however works on only with text…

Works
$('table').find('tbody').before( \"<tr><td><div>hhhh</div></td></tr>\" );");

Doesn’t work
$('table').find('tbody').before( \"<tr><td><div style=\"color:red;\">hhhh</div></td></tr>\" );");

#2

Hi @letsforum, actually neither line should work as the escape character outside the string is a syntax error, and there’s an excess closing paren + semicolon at the end of each. If you fixed that both lines should work as intended though.