2

I'm trying to put content of a JSON in the HTML table but content is filled in the rows ,and I would like to be filled in the columns.

My JSON :

var serie=
{

"keywords":[["CELL","CELL2","CELL3"]]
} 

My JQuery code:

$.each(serie.keywords, function () {

    $.each(this, function (k,v) {
      var eachrow = "<tr>" 
                 + "<td>" + v + "</td>"
                 + "</tr>";
         $('#tbody').append(eachrow);

        }); 

});

As result I have soething like this:

CELL
-----
CELL2
-----
CELL3

And I would like that it will be like that:

CELL|CELL2|CELL3

Thanks for your help!!!

1 Answer 1

2

Try,

$.each(serie.keywords, function () { 

    var eachrow = "<tr>";

    $.each(this, function (k,v) {
        eachrow += "<td>" + v + "</td>";
    }); 
    eachrow += "</tr>";

    $('#tbody').append(eachrow);

});
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.