<html>
<body>
<h2>JSON Object Creation in JavaScript</h2>
<p>
Name: <span id="jname"></span><br />
Age: <span id="jage"></span><br />
Address: <span id="jstreet"></span><br />
Phone: <span id="jphone"></span><br />
Memo: <span id="jmemo"></span><br />
</p>
<script type="text/javascript">
var JSONObject = {
"name":"John Johnson",
"street":"Oslo West 16",
"age":33,
"phone":"555 1234567",
"memo":"hello world !"};
document.getElementById("jname").innerHTML=JSONObject.name
document.getElementById("jage").innerHTML=JSONObject.age
document.getElementById("jstreet").innerHTML=JSONObject.street
document.getElementById("jphone").innerHTML=JSONObject.phone
document.getElementById("jmemo").innerHTML=JSONOject.memo
</script>
</body>
</html>
我得到的结果是:
JSON Object Creation in Javascript
Name: John Johnson
Age: 33
Address: Oslo West 16
Phone: 555 1234567
Memo:
为什么在“备忘录”之后,没有像我预期的“Hello World”? 谢谢!
答案 0 :(得分:3)
document.getElementById("jmemo").innerHTML=JSONOject.memo
应该是
document.getElementById("jmemo").innerHTML=JSONObject.memo