遍历属性值
- <!DOCTYPE html>
- <html>
- <body>
- <h1>JSON 对象</h1>
- <p>使用括号表示法访问属性值。</p>
- <p id="demo"></p>
- <script>
- var myObj, x;
- myObj = {"name":"Bill Gates", "age":62, "car":null};
- for (x in myObj) {
- document.getElementById("demo").innerHTML += myObj[x] + "<br>";
- }
- </script>
- </body>
- </html>