HTML Editor
<!DOCTYPE html> <html lang="en-US"> <body> <h1>JSON Objects</h1> <p id="point"></p> <button onclick="myFunction()">Click Me</button> <script> var data = [ { "name": "Mike", "age": 36, "id": { "eyes": "brown", "hair": "blonde" } }, { "name": "Alex", "age": 30, "id": { "eyes": "blue", "hair": "brunette" } } ] function myFunction(){ document.getElementById("point").innerHTML = data[0].id.hair; } </script> <p><strong>Note</strong>: Click on the button to get the hair color of 'Mike'.</p> </body> </html>
OUTPUT
×

Save as Private