欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

jQuery實(shí)現(xiàn)簡(jiǎn)單復(fù)制json對(duì)象和json對(duì)象集合操作示例

 更新時(shí)間:2018年07月09日 10:15:07   作者:曹振華  
這篇文章主要介紹了jQuery實(shí)現(xiàn)簡(jiǎn)單復(fù)制json對(duì)象和json對(duì)象集合操作,結(jié)合實(shí)例形式分析了jQuery使用extend方法操作json對(duì)象與json對(duì)象集合復(fù)制相關(guān)技巧,需要的朋友可以參考下

本文實(shí)例講述了jQuery實(shí)現(xiàn)簡(jiǎn)單復(fù)制json對(duì)象和json對(duì)象集合操作。分享給大家供大家參考,具體如下:

<!DOCTYPE html>
<html>
<head>
  <meta name="viewport" content="width=device-width" />
  <title>www.dbjr.com.cn jQuery復(fù)制json</title>
  <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
  <script type="text/javascript">
    $(function () {
      var classList = [
        {
          classId: 1, className: '一班', students: [
           { studentId: 1, studentName: '張三' },
           { studentId: 2, studentName: '李四' }
          ]
        },
        {
          classId: 2, className: '二班', students: [
           { studentId: 3, studentName: '王五' },
           { studentId: 4, studentName: '馬六' }
          ]
        }
      ]
      var classDemo = {
        classId: 1, className: '一班', students: [
         { studentId: 1, studentName: '張三' },
         { studentId: 2, studentName: '李四' }
        ]
      }
      var newClassList = jQuery.extend(true, [], classList);//復(fù)制對(duì)象集合
      var newClassDemo = jQuery.extend(true, {}, classDemo);//復(fù)制對(duì)象
      //輸出測(cè)試:
      console.log(newClassList);
      console.log(newClassDemo);
    });
  </script>
</head>
<body>
</body>
</html>

使用本站HTML/CSS/JS在線運(yùn)行測(cè)試工具http://tools.jb51.net/code/HtmlJsRun,可得到如下測(cè)試運(yùn)行效果:

PS:關(guān)于json操作,這里再為大家推薦幾款比較實(shí)用的json在線工具供大家參考使用:

在線JSON代碼檢驗(yàn)、檢驗(yàn)、美化、格式化工具:
http://tools.jb51.net/code/json

JSON在線格式化工具:
http://tools.jb51.net/code/jsonformat

在線XML/JSON互相轉(zhuǎn)換工具:
http://tools.jb51.net/code/xmljson

json代碼在線格式化/美化/壓縮/編輯/轉(zhuǎn)換工具:
http://tools.jb51.net/code/jsoncodeformat

在線json壓縮/轉(zhuǎn)義工具:
http://tools.jb51.net/code/json_yasuo_trans

更多關(guān)于jQuery相關(guān)內(nèi)容感興趣的讀者可查看本站專(zhuān)題:《jQuery操作json數(shù)據(jù)技巧匯總》、《jQuery常用插件及用法總結(jié)》、《jQuery擴(kuò)展技巧總結(jié)》及《jquery選擇器用法總結(jié)

希望本文所述對(duì)大家jQuery程序設(shè)計(jì)有所幫助。

相關(guān)文章

最新評(píng)論