3

I have an array (encoded in JSON) in jQuery. Let's say the array is item1 : item1, item2 : item2, item3 : item3. I need to loop through the results and print a table. How would I go about doing this?

1 Answer 1

3
<table>
</table>
<script type="text/javascript">
    var data = {key1: "val1", key2: "val2"};
    for (var key in data) {
       $('table').append('<tr><td>' + data[key] + '</td></tr>');
    }
</script>
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.