json的循环内嵌数组:对json的遍历
来源:互联网 发布:淘宝网 迪士尼儿童床 编辑:程序博客网 时间:2024/05/11 18:58
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title><script type="text/javascript" src="jquery-2.1.1.js"></script>
</head>
<body>
<p>循环内嵌数组:</p>
<p id="demo"></p>
<script>
var myObj,i,j,str="";
myObj = {
"name":"网站",
"num":3,
"sites": [
{ "name":"Google", "info":[ "Android", "Google 搜索", "Google 翻译" ] },
{ "name":"Runoob", "info":[ "菜鸟教程", "菜鸟工具", "菜鸟微信" ] },
{ "name":"Taobao", "info":[ "淘宝", "网购" ] }
]
}
for(i in myObj.sites)
{
str+="<span class='ddd'><h1>"+myObj.sites[i].name+"</h1></span>";
for(j in myObj.sites[i].info)
{
str+="<span class='fff'>"+myObj.sites[i].info[j]+"</span><br/>";
}
}
$("#demo").html(str);
$(".ddd").click(function(){
$(".fff").toggle();
});
</script>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title><script type="text/javascript" src="jquery-2.1.1.js"></script>
</head>
<body>
<p>循环内嵌数组:</p>
<p id="demo"></p>
<script>
var myObj,i,j,str="";
myObj = {
"name":"网站",
"num":3,
"sites": [
{ "name":"Google", "info":[ "Android", "Google 搜索", "Google 翻译" ] },
{ "name":"Runoob", "info":[ "菜鸟教程", "菜鸟工具", "菜鸟微信" ] },
{ "name":"Taobao", "info":[ "淘宝", "网购" ] }
]
}
for(i in myObj.sites)
{
str+="<span class='ddd'><h1>"+myObj.sites[i].name+"</h1></span>";
for(j in myObj.sites[i].info)
{
str+="<span class='fff'>"+myObj.sites[i].info[j]+"</span><br/>";
}
}
$("#demo").html(str);
$(".ddd").click(function(){
$(".fff").toggle();
});
</script>
</body>
</html>
阅读全文
0 0
- json的循环内嵌数组:对json的遍历
- JS循环遍历JSON数组
- js遍历数组 循环json数组
- jquery 对 Json 的各种遍历
- jquery 对 Json 的各种遍历
- jquery 对 Json 的各种遍历
- jquery 对 Json 的各种遍历
- jquery 对 Json 的各种遍历
- jquery 对 Json 的各种遍历
- jquery 对 Json 的各种遍历
- jquery 对 Json 的各种遍历
- jquery 对 Json 的各种遍历
- jquery 对 Json 的各种遍历
- jquery 对 Json 的各种遍历
- jquery 对 Json 的各种遍历
- json数组使用jquery each循环遍历
- json解析构造与json数组的遍历
- jquery遍历三维数组形成的json
- 关于document.getElementById与document.getElementByName
- HBase(二)
- 提醒大家有关越狱组it学院vip会员有猫腻,要小心。。。
- leetcode 652. Find Duplicate Subtrees
- Mybatis中 if test 判断数值字符串注意项
- json的循环内嵌数组:对json的遍历
- 页面使用本地静态资源解决方法
- 【转载】MDK 中的逻辑分析仪参与HARDWARE DEBUG
- ThreadLocal
- jQuery Placeholder Plugin源码分析
- darts_builder
- POJ-1602 昂贵的聘礼
- zip命令
- 苹果Siri已哭晕在沙滩上,感慨中国人工智能实在太强