Avatar of erzoolander
erzoolander
 asked on

Build DOM elements from JSON / JQuery

I've got a JSON string that takes this form...

{"people":[{"name":"person1","description":"This is a brief description of my service.","image":"mandg1.jpg","type":"first","insured":"yes","license":"N\/A","picture":"mandg1.jpg","yearsinbusiness":"8","distance":15},{"name":"person2","description":"This is a brief description of my service.","image":"mandg2.jpg","type":"second","insured":"yes","license":"N\/A","picture":"mandg2.jpg","yearsinbusiness":"8","distance":19}]}

What I'd like to do is, via jQuery, build a group of divs based upon the "people" key...so in the instance above...you'd end up creating 2 elements...and append them to the div id="container".  If there were 50 elements, you'd end up with 50 divs, etc etc etc.

<div id="container">
<div id="person1">
<p>Name: person1</p>
<p>Description: This is a brief description of my service</p>
</div>
<div id="person2">
<p>Name: person2</p>
<p>Description: This is a brief description of my service</p>
</div>
</div>

What would the jQuery syntax for that be?  Thanks in advance!
JavaScriptjQuery

Avatar of undefined
Last Comment
erzoolander

8/22/2022 - Mon
SOLUTION
hielo

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
ASKER CERTIFIED SOLUTION
nap0leon

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
erzoolander

ASKER
Gracias!
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes