functionshowJSON(){varuser={"username":"andy","age":20,"info":{"tel":"123456","cellphone":"98765"},"address":[{"city":"beijing","postcode":"222333"},{"city":"newyork","postcode":"555666"}]}alert(user.username);alert(user.age);alert(user.info.cellphone);alert(user.address[0].city);alert(user.address[0].postcode);}如何在页面显示alert(user.username);alert(user.age);alert(user.info.cellphone);alert(user.address[0].city);alert(user.address[0].postcode);这些要显示的属性在body里面要怎么写?
2 回答
有只小跳蛙
那么document.getElementById('content').innerHTML='xxx';
TA贡献1824条经验 获得超8个赞
如果只是要简单地写在页面上,用document.write。如果要放在一个div里面,例如