jquery - create DOM elements with data value from a javascript -


i have site basic information outpout in javscript. don't have access server side of things - , wonder if use jquery/vanilla js create dom element value script?

the script looks this:

var retailerdata = {     "del": {         "zip": "",         "city": ""     },     "user": {         "country": "denmark",         "phone": "0000",         "nbrorders": 0,         "name": "john doe",         "salesperson": "frederik jensen",         "customerno": "5464564564",         "email": "johndoe@test.dk"     },     "order": {         "shippingsum": 0.0,         "orderno": "",         "voucher": "",         "currency": "",         "ordervat": 0.0,         "ordersum": 0.0,         "items": []     } } 

small example:

var retailerdata = {"del":{"zip":"","city":""},"user":{"country":"denmark","phone":"0000","nbrorders":0,"name":"john doe","salesperson":"frederik jensen","customerno":"5464564564","email":"johndoe@test.dk"},"order":{"shippingsum":0.0,"orderno":"","voucher":"","currency":"","ordervat":0.0,"ordersum":0.0,"items":[]}}  var maindiv = document.createelement("div");         var text1 = document.createtextnode("user details");   var countrydiv = document.createelement("div"); var text2 = document.createtextnode("country:");   var text3 = document.createtextnode(retailerdata.user.country);    countrydiv.appendchild(text2) countrydiv.appendchild(text3) maindiv.appendchild(text1);   maindiv.appendchild(countrydiv); document.body.appendchild(maindiv);    

Comments

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

reactjs - React router and this.props.children - how to pass state to this.props.children -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -