jQuery實現(xiàn)簡單復(fù)制json對象和json對象集合操作示例
本文實例講述了jQuery實現(xiàn)簡單復(fù)制json對象和json對象集合操作。分享給大家供大家參考,具體如下:
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>www.dhdzp.com 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ù)制對象集合
var newClassDemo = jQuery.extend(true, {}, classDemo);//復(fù)制對象
//輸出測試:
console.log(newClassList);
console.log(newClassDemo);
});
</script>
</head>
<body>
</body>
</html>
使用本站HTML/CSS/JS在線運行測試工具:http://tools.jb51.net/code/HtmlJsRun,可得到如下測試運行效果:

PS:關(guān)于json操作,這里再為大家推薦幾款比較實用的json在線工具供大家參考使用:
在線JSON代碼檢驗、檢驗、美化、格式化工具:
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)容感興趣的讀者可查看本站專題:《jQuery操作json數(shù)據(jù)技巧匯總》、《jQuery常用插件及用法總結(jié)》、《jQuery擴展技巧總結(jié)》及《jquery選擇器用法總結(jié)》
希望本文所述對大家jQuery程序設(shè)計有所幫助。
相關(guān)文章
jquery結(jié)合css實現(xiàn)返回頂部功能
在本篇文章里小編給大家整理了一篇關(guān)于jquery結(jié)合css實現(xiàn)返回頂部功能的相關(guān)文章,有興趣的朋友們可以實例測試下。2021-08-08
IE中jquery.form中ajax提交沒反應(yīng)解決方法分享
用jquery form插件,進行ajax提交,本來可以用,好好地,突然發(fā)現(xiàn),firefox,opera等可以提交,ie的success函數(shù)運行了2012-09-09
jq stop()和:is(:animated)的用法及區(qū)別(詳解)
下面小編就為大家?guī)硪黄猨q stop()和:is(:animated)的用法及區(qū)別(詳解)。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2017-02-02
基于jquery插件制作左右按鈕與標(biāo)題文字圖片切換效果
制作左右按鈕與標(biāo)題文字圖片切換效果的方法有很多,在本文為大家介紹下使用jquery圖片切換插件是如何實現(xiàn)的,感興趣的朋友不要錯過2013-11-11

