json
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了json,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2436字,纯文字阅读大概需要4分钟。
内容图文
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Our superheroes</title> <link href="https://fonts.googleapis.com/css?family=Faster+One" rel="stylesheet"> <link rel="stylesheet" href="./style.css"> <title>JSON</title> </head> <body> <header> <div> </div> </header> <section> </section> <script src="./script/main.js"></script> </body> </html>
header h1{ width: 100%; text-align: center; font-size: 50px; font-family: 楷体; } section{ width: 100%; display: inline-flex; } section p{ margin:0; font-size: 30px; font-family: 楷体; color: rgb(0, 0, 0); width: 100%; } div{ width: 33%; } section p2{ margin:0; font-size: 30px; font-family: 楷体; color: rgb(3, 3, 3); width: 33%; } section p3{ margin:0; font-size: 25px; font-family: 楷体; color: rgb(0, 0, 0); width: 33%; }
var header = document.querySelector(‘header‘); var section = document.querySelector(‘section‘); var requestURL = ‘https://wcphaha.github.io/for-football/Sports.json‘; var request = new XMLHttpRequest(); request.open(‘GET‘, requestURL); request.responseType = ‘json‘; request.send(); request.onload = function () { var inter = request.response; console.log(inter) showname(inter); showteam(inter); } function showname(jsonObj) { var h = document.createElement(‘h1‘); h.textContent = jsonObj[‘team‘]; header.appendChild(h) } function showteam(jsonObj) { var p1 = new Array(4); var part1 = document.querySelector(‘div‘); for (var i = 0; i < 4; i++) p1[i] = document.createElement(‘p‘); p1[0].textContent = "哈斯:" + jsonObj[‘address‘]; p1[1].textContent = "时间卡:" + jsonObj[‘field‘]; p1[2].textContent = "萨满打开里面:" + jsonObj[‘chairman‘]; p1[3].textContent = "澳门克莱德曼:" + jsonObj[‘coach‘]; for (i = 0;i<4; i++) part1.appendChild(p1[i]); section.appendChild(part1); var honor = jsonObj[‘honor‘]; var p2=document.createElement(‘p2‘); for (var i = 0; i < 6; i++) { var list = document.createElement(‘li‘); list.textContent=honor[i]; p2.appendChild(list); } section.appendChild(p2); var member = jsonObj[‘member‘]; var p3 = document.createElement(‘p3‘); for(var i=0;i<16;i++){ var list = document.createElement(‘li‘); list.textContent=member[i].name+‘(‘+member[i].number+‘)‘+‘--‘+member[i].position+‘--‘+member[i].nationality; p3.appendChild(list); } section.appendChild(p3); }
原文:https://www.cnblogs.com/NineKit/p/10006821.html
内容总结
以上是互联网集市为您收集整理的json全部内容,希望文章能够帮你解决json所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。