Jax-p Jax-p - 4 months ago 12
jQuery Question

How to appendChild() on Jquery selected DOM

I am trying to append child via jQuery to the on of selected HTML element.

My code:

var table = $(this).parent();
console.log(table)
table.appendChild(table_row);


Console:

[table.table.unit-list, prevObject: jQuery.fn.init[1], context: tr] //log
... appendChild is not a function //error

Answer

Just use .append()

Description: Insert content, specified by the parameter, to the end of each element in the set of matched elements.

table.append(table_row);

Read about Difference between append and appendChild

Comments