I have a question, I have a function in JavaScript to generate tables, in the following way:
function AgregarTabla(idContenedor, idTabla) {
var htmlTabla;
htmlTabla=
"<table id = '" + idTabla + "'>\n\
<thead>\n\
<tr bgcolor='FFFDC1'>\n\
<th>Columna 1</th>\n\
<th>Column 2</th>\n\
<th>Columna 3</th>\n\
</tr>\n\
</thead>\n\
</table>";
$("#" + idContenedor).append(GenerarTabla);
}
As you can see, it is written in text / html format, but I would like to know if there is any way to write the same but in JQuery format. I understand that something like this should be done:
var jQueryTabla = $("<table></table>");
jQueryTabla.attr({
id:idTabla});
$("#" + idContenedor).append(GenerarTabla);
But then I do not know how to add the tr and th.
Thank you in advance. Greetings.