jquery通过把json数据转换输出为table表格插件

所属分类: 网页特效-实用工具    2023-08-03 10:39:40

jquery通过把json数据转换输出为table表格插件 ie兼容6
 查看演示  登录后下载 温馨提示
登录会员即可享受免费下载
 我要建站

jquery通过把json数据转换输出为table表格插件(共9个文件)

    • index.html

使用方法

		$(document).ready(function() {
			var arr = [
					[1, 2, 3],
					["one", "two", "three"]
			];

      /* Array To Table */
      var input = JSON.stringify(arr);
			$("#jsontotable-arr")
        .append($("

").html("Array To Table")) .append($("

").html("Input")) .append($("").html(input)) .append($("

").html("Output")); $.jsontotable(arr, { id: "#jsontotable-arr", header: true }); /* Array To Table (Without Header) */ $("#jsontotable-arr") .append($("

").html("Array To Table (Without Header)")) .append($("

").html("Input")) .append($("").html(input)) .append($("

").html("Output")); $.jsontotable(arr, { id: "#jsontotable-arr", header: false }); var obj = [ {"Title1": "Hello", "Title2": "Fine", "Title3": "Thank you"}, {"Title1": "안녕하세요", "Title2": "좋아요", "Title3": "감사합니다"}, {"Title1": "こんにちは", "Title2": "ファイン", "Title3": "ありがとう"}, {"Title1": "你好", "Title2": "精", "Title3": "谢谢"}, {"Title1": "Bonjour", "Title2": "Beaux", "Title3": "Merci"}, {"Title1": "Ciao", "Title2": "Bene", "Title3": "Grazie"} ]; /* JSON To Table (Has Header) */ input = JSON.stringify(obj); $("#jsontotable-obj") .append($("

").html("JSON To Table (Has Header)")) .append($("

").html("Input")) .append($("").html(input)) .append($("

").html("Output")); $.jsontotable(obj, { id: "#jsontotable-obj" }); /* JSON To Table (Without Header) */ $("#jsontotable-obj") .append($("

").html("JSON To Table (Without Header)")) .append($("

").html("Input")) .append($("").html(input)) .append($("

").html("Output")); $.jsontotable(obj, { id: "#jsontotable-obj", header: false }); var objmissing = [ {"Title1": "Hello", "Title2": "Fine", "Title3": "Thank you"}, {"Title1": "안녕하세요", "Title2": "좋아요", "Title3": "감사합니다"}, {"Title4": "こんにちは", "Title2": "ファイン", "Title5": "ありがとう"}, {"Title1": "你好", "Title5": "精", "Title3": "谢谢"}, {"Title5": "Bonjour", "Title4": "Beaux", "Title3": "Merci"}, {"Title1": "Ciao", "Title6": "Bene", "Title7": "Grazie"} ]; /* JSON To Table (Has Header and Missing some columns in body */ input = JSON.stringify(objmissing); $("#jsontotable-obj") .append($("

").html("JSON To Table (Has Header and Missing some columns in body)")) .append($("

").html("Input")) .append($("").html(input)) .append($("

").html("Output")); $.jsontotable(objmissing, { id: "#jsontotable-obj" , header: true }); var objwithdata = [ { id: "header", "class": "header-class", _data:{"Title1": "안녕하세요", "Title2": "좋아요", "Title3": "감사합니다"} }, {"Title1": "안녕하세요", "Title2": "좋아요", "Title3": "감사합니다"}, {"Title1": "こんにちは", "Title2": "ファイン", "Title3": "ありがとう"}, {"Title1": "你好", "Title2": "精", "Title3": "谢谢"}, {"Title1": "Bonjour", "Title2": "Beaux", "Title3": "Merci"}, {"Title1": "Ciao", "Title2": "Bene", "Title3": "Grazie"} ]; /* JSON To Table with _data attribute (Has Header) */ input = JSON.stringify(objwithdata); $("#jsontotable-objwithdata") .append($("

").html("JSON To Table with _data attribute (Has Header)")) .append($("

").html("Input")) .append($("").html(input)) .append($("

").html("Output")); $.jsontotable(objwithdata, { id: "#jsontotable-objwithdata" }); /* JSON To Table with _data attribute (Without Header) */ $("#jsontotable-objwithdata") .append($("

").html("JSON To Table with _data attribute (Without Header)")) .append($("

").html("Input")) .append($("").html(input)) .append($("

").html("Output")); $.jsontotable(objwithdata, { id: "#jsontotable-objwithdata", header: false }); var str = "[\ {\"Title1\": \"Hello\", \"Title2\": \"Fine\", \"Title3\": \"Thank you\"}, \ {\"Title1\": \"안녕하세요\", \"Title2\": \"좋아요\", \"Title3\": \"감사합니다\"}, \ {\"Title1\": \"こんにちは\", \"Title2\": \"ファイン\", \"Title3\": \"ありがとう\"}, \ {\"Title1\": \"你好\", \"Title2\": \"精\", \"Title3\": \"谢谢\"}, \ {\"Title1\": \"Bonjour\", \"Title2\": \"Beaux\", \"Title3\": \"Merci\"}, \ {\"Title1\": \"Ciao\", \"Title2\": \"Bene\", \"Title3\": \"Grazie\"} \ ]"; /* JSON (String Format) To Table" */ $("#jsontotable-str") .append($("

").html("JSON (String Format) To Table")) .append($("

").html("Input")) .append($("").html(input)) .append($("

").html("Output")); $.jsontotable(str, { id: "#jsontotable-str", className: "table table-bordered table-striped" }); });

站长提示:
1. 苦力吧素材官方QQ群:950875342
2. 平台上所有素材资源,需注册登录会员方能正常下载。
3. 会员用户积极反馈网站、素材资源BUG或错误问题,每次奖励2K币
4. PHP源码类素材,如需协助安装调试,或你有二次开发需求,可联系苦力吧客服。
5. 付费素材资源,需充值后方能下载,如有任何疑问可直接联系苦力吧客服
相关资源 / 实用工具

jquery支持自定义布局的在线选座插件

一款在线选座插件,可自定义座位布局,适用场景:教室座位/电影院/飞机座位预订系统,支持已选座位,座位分类功能。
  实用工具
 7745  0

javascript创建的温度计滑块小部件

一款可在线滑动调节的温度计插件,滑块可修改介于-20°C到50°C或华氏度之间的温度值。点击摄氏度可切换到华氏度界面,拖动滑块可设置温度值。
  实用工具
 41124  0

jquery点击按钮可放大缩小页面插件

可自由放大缩小整个页面,使得页面元素:图片、文字等同步达到放大缩小效果。
  实用工具
 1764  0

jquery轻量级可拖拽移动关闭的对话框窗口

jDoor是一个轻量级精仿windows窗口插件,支持鼠标拖放移动关闭,还可以自定义加载外部网站视频位于窗口内,超实用。
  实用工具
 7752  0

评论数(0) 回复有机会获得K币 用户协议

^_^ 还没有人评论,快来抢个沙发!
😀
  • 😀
  • 😊
  • 😂
  • 😍
  • 😑
  • 😷
  • 😵
  • 😛
  • 😣
  • 😱
  • 😋
  • 😎
  • 😵
  • 😕
  • 😶
  • 😚
  • 😜
  • 😭
发表评论