Kirsty White
Kirsty White

Reputation: 1220

how to add multiple elements from json file to html

I have a object and I attempting to add both the name and description to the html body:

$('div#mydiv').html((j.root[D - 1].Name), (j.root[D - 1].Description));

However only the name is showing when I run it?

Upvotes: 0

Views: 49

Answers (1)

Barmar
Barmar

Reputation: 780798

.html does not take multiple arguments. Use + for concatenation to combine all the strings into a single argument.

$('div#mydiv').html(j.root[D-1].Name + ' ' + j.root[D-1].Description);

Upvotes: 2

Related Questions