Skip to content Skip to sidebar Skip to footer

Generating From JSON To HTML Table Based On ID

So I am pretty much brand new to JSON and fairly new to jquery. I've been trying to learn how to generate an HTML table based on the JSON data. But more importantly, I'm going to h

Solution 1:

The first part of

tr = $('<tr/>');

Is unnecessary, it returns nothing, to fetch an html element using jquery you simply put it's tag name / class name / Id inside the quotes.

$('table')
$('.class') 
$('#id') 

To put your generated tr (which is practically an html in the form of a string) into the table you use the append function on the table like so

$('#tableID').append(tr) 

When you're using the table tag name it takes all the tables on the current page and appends your tr to them.


Post a Comment for "Generating From JSON To HTML Table Based On ID"