E. Hoxha E. Hoxha - 9 months ago 41
Javascript Question

Why is jQuery append function not appending the table?

I've been looking around here on stackoverflow, found lots of approved answers but none could help me.

So what I can basically come up with is this table code

<table id="tableid" class="table table-responsive">
<tbody id="tbItems">
<button type="button" id="btnAddItem" onclick="addProduct">Add</button>

and this js code

var $tableS = $('#tableid');

function addProduct() {

but I have 0 ideas as to why it's not working.

Link to jsfiddle: https://jsfiddle.net/LvvbLcn2/1/

Answer Source

You missed brackets in the onclick attribute:

<button type="button" id="btnAddItem" onclick="addProduct">Add</button>

Here the working example on jsfiddle:


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download