Loading... <ol start="1" class="dp-c" style="padding:0px;border:none;color:#5C5C5C;font-family:Consolas, 'Courier New', Courier, mono, serif;line-height:26px;white-space:normal;margin:0px 0px 1px 45px !important;background-color:#FFFFFF;"> <li class="alt" style="margin:0px !important;padding:0px 3px 0px 10px !important;border-style:none none none solid;border-left-width:3px;border-left-color:#999999;list-style:decimal-leading-zero outside;color:inherit;line-height:18px;background-color:#F5FAE2;"> <span style="margin:0px;padding:0px;border:none;color:black;background-color:inherit;"><span class="keyword" style="margin:0px;padding:0px;border:none;color:blue;font-weight:bold;background-color:inherit;">var</span><span style="margin:0px;padding:0px;border:none;background-color:inherit;"> data=[{name:</span><span class="string" style="margin:0px;padding:0px;border:none;color:red;background-color:inherit;">"a"</span><span style="margin:0px;padding:0px;border:none;background-color:inherit;">,age:12},{name:</span><span class="string" style="margin:0px;padding:0px;border:none;color:red;background-color:inherit;">"b"</span><span style="margin:0px;padding:0px;border:none;background-color:inherit;">,age:11},{name:</span><span class="string" style="margin:0px;padding:0px;border:none;color:red;background-color:inherit;">"c"</span><span style="margin:0px;padding:0px;border:none;background-color:inherit;">,age:13},{name:</span><span class="string" style="margin:0px;padding:0px;border:none;color:red;background-color:inherit;">"d"</span><span style="margin:0px;padding:0px;border:none;background-color:inherit;">,age:14}]; </span></span> </li> <li class="" style="margin:0px !important;padding:0px 3px 0px 10px !important;border-style:none none none solid;border-left-width:3px;border-left-color:#999999;list-style:decimal-leading-zero outside;color:#555555;line-height:18px;background-color:#F5FAE2;"> <span style="margin:0px;padding:0px;border:none;color:black;background-color:inherit;"> <span class="keyword" style="margin:0px;padding:0px;border:none;color:blue;font-weight:bold;background-color:inherit;">for</span><span style="margin:0px;padding:0px;border:none;background-color:inherit;">(</span><span class="keyword" style="margin:0px;padding:0px;border:none;color:blue;font-weight:bold;background-color:inherit;">var</span><span style="margin:0px;padding:0px;border:none;background-color:inherit;"> o </span><span class="keyword" style="margin:0px;padding:0px;border:none;color:blue;font-weight:bold;background-color:inherit;">in</span><span style="margin:0px;padding:0px;border:none;background-color:inherit;"> data){ </span></span> </li> <li class="alt" style="margin:0px !important;padding:0px 3px 0px 10px !important;border-style:none none none solid;border-left-width:3px;border-left-color:#999999;list-style:decimal-leading-zero outside;color:inherit;line-height:18px;background-color:#F5FAE2;"> <span style="margin:0px;padding:0px;border:none;color:black;background-color:inherit;"> alert(o); </span> </li> <li class="" style="margin:0px !important;padding:0px 3px 0px 10px !important;border-style:none none none solid;border-left-width:3px;border-left-color:#999999;list-style:decimal-leading-zero outside;color:#555555;line-height:18px;background-color:#F5FAE2;"> <span style="margin:0px;padding:0px;border:none;color:black;background-color:inherit;"> alert(data[o]); </span> </li> <li class="alt" style="margin:0px !important;padding:0px 3px 0px 10px !important;border-style:none none none solid;border-left-width:3px;border-left-color:#999999;list-style:decimal-leading-zero outside;color:inherit;line-height:18px;background-color:#F5FAE2;"> <span style="margin:0px;padding:0px;border:none;color:black;background-color:inherit;"> alert(<span class="string" style="margin:0px;padding:0px;border:none;color:red;background-color:inherit;">"text:"</span><span style="margin:0px;padding:0px;border:none;background-color:inherit;">+data[o].name+</span><span class="string" style="margin:0px;padding:0px;border:none;color:red;background-color:inherit;">" value:"</span><span style="margin:0px;padding:0px;border:none;background-color:inherit;">+data[o].age ); </span></span> </li> <li class="" style="margin:0px !important;padding:0px 3px 0px 10px !important;border-style:none none none solid;border-left-width:3px;border-left-color:#999999;list-style:decimal-leading-zero outside;color:#555555;line-height:18px;background-color:#F5FAE2;"> <span style="margin:0px;padding:0px;border:none;color:black;background-color:inherit;"> </span><span style="color:black;background-color:inherit;"> } </span> </li> </ol> <p> <div class="bar" style="padding-left:45px;font-family:Consolas, 'Courier New', Courier, mono, serif;line-height:26px;white-space:normal;"> <div class="tools" style="padding:3px 8px 10px 10px;font-stretch:normal;font-size:9px;line-height:normal;font-family:Verdana, Geneva, Arial, Helvetica, sans-serif;color:silver;border-left-width:3px;border-left-style:solid;border-left-color:#999999;background-color:#F8F8F8;"> <b>[javascript]</b> <a href="http://blog.csdn.net/songylwq/article/details/6047609#" class="ViewSource" title="view plain" style="color:#A0A0A0;text-decoration:none;border:none;padding:0px;margin:0px 10px 0px 0px;background-image:none;background-attachment:initial;background-color:inherit;background-size:initial;background-origin:initial;background-clip:initial;background-position:initial;background-repeat:initial;">view plain</a><span class="tracking-ad" data-mod="popu_168"> <a href="http://blog.csdn.net/songylwq/article/details/6047609#" class="CopyToClipboard" title="copy" style="color:#A0A0A0;text-decoration:none;border:none;padding:0px;margin:0px 10px 0px 0px;background-image:none;background-attachment:initial;background-color:inherit;background-size:initial;background-origin:initial;background-clip:initial;background-position:initial;background-repeat:initial;">copy</a> <div style="position:absolute;left:626px;top:820px;width:27px;height:15px;z-index:99;"> </div> </span><span class="tracking-ad" data-mod="popu_169"> <a href="http://blog.csdn.net/songylwq/article/details/6047609#" class="PrintSource" title="print" style="color:#A0A0A0;text-decoration:none;border:none;padding:0px;margin:0px 10px 0px 0px;background-image:none;background-attachment:initial;background-color:inherit;background-size:initial;background-origin:initial;background-clip:initial;background-position:initial;background-repeat:initial;">print</a></span><a href="http://blog.csdn.net/songylwq/article/details/6047609#" class="About" title="?" style="color:#A0A0A0;text-decoration:none;border:none;padding:0px;margin:0px 10px 0px 0px;background-image:none;background-attachment:initial;background-color:inherit;background-size:initial;background-origin:initial;background-clip:initial;background-position:initial;background-repeat:initial;">?</a> jquery </div> </div> <ol start="1" class="dp-c" style="padding:0px;border:none;color:#5C5C5C;font-family:Consolas, 'Courier New', Courier, mono, serif;line-height:26px;white-space:normal;margin:0px 0px 1px 45px !important;background-color:#FFFFFF;"> <li class="alt" style="margin:0px !important;padding:0px 3px 0px 10px !important;border-style:none none none solid;border-left-width:3px;border-left-color:#999999;list-style:decimal-leading-zero outside;color:inherit;line-height:18px;background-color:#F5FAE2;"> <span style="margin:0px;padding:0px;border:none;color:black;background-color:inherit;"><span style="margin:0px;padding:0px;border:none;background-color:inherit;"><script type=</span><span class="string" style="margin:0px;padding:0px;border:none;color:red;background-color:inherit;">"text/javascript"</span><span style="margin:0px;padding:0px;border:none;background-color:inherit;">> </span></span> </li> <li class="" style="margin:0px !important;padding:0px 3px 0px 10px !important;border-style:none none none solid;border-left-width:3px;border-left-color:#999999;list-style:decimal-leading-zero outside;color:#555555;line-height:18px;background-color:#F5FAE2;"> <span style="margin:0px;padding:0px;border:none;color:black;background-color:inherit;"><span class="keyword" style="margin:0px;padding:0px;border:none;color:blue;font-weight:bold;background-color:inherit;">function</span><span style="margin:0px;padding:0px;border:none;background-color:inherit;"> text(){ </span></span> </li> <li class="alt" style="margin:0px !important;padding:0px 3px 0px 10px !important;border-style:none none none solid;border-left-width:3px;border-left-color:#999999;list-style:decimal-leading-zero outside;color:inherit;line-height:18px;background-color:#F5FAE2;"> <span style="margin:0px;padding:0px;border:none;color:black;background-color:inherit;"> <span class="keyword" style="margin:0px;padding:0px;border:none;color:blue;font-weight:bold;background-color:inherit;">var</span><span style="margin:0px;padding:0px;border:none;background-color:inherit;"> json = {</span><span class="string" style="margin:0px;padding:0px;border:none;color:red;background-color:inherit;">"options"</span><span style="margin:0px;padding:0px;border:none;background-color:inherit;">:</span><span class="string" style="margin:0px;padding:0px;border:none;color:red;background-color:inherit;">"[{/"</span><span style="margin:0px;padding:0px;border:none;background-color:inherit;">text/</span><span class="string" style="margin:0px;padding:0px;border:none;color:red;background-color:inherit;">":/"</span><span style="margin:0px;padding:0px;border:none;background-color:inherit;">王家湾/</span><span class="string" style="margin:0px;padding:0px;border:none;color:red;background-color:inherit;">",/"</span><span style="margin:0px;padding:0px;border:none;background-color:inherit;">value/</span><span class="string" style="margin:0px;padding:0px;border:none;color:red;background-color:inherit;">":/"</span><span style="margin:0px;padding:0px;border:none;background-color:inherit;">9/</span><span class="string" style="margin:0px;padding:0px;border:none;color:red;background-color:inherit;">"},{/"</span><span style="margin:0px;padding:0px;border:none;background-color:inherit;">text/</span><span class="string" style="margin:0px;padding:0px;border:none;color:red;background-color:inherit;">":/"</span><span style="margin:0px;padding:0px;border:none;background-color:inherit;">李家湾/</span><span class="string" style="margin:0px;padding:0px;border:none;color:red;background-color:inherit;">",/"</span><span style="margin:0px;padding:0px;border:none;background-color:inherit;">value/</span><span class="string" style="margin:0px;padding:0px;border:none;color:red;background-color:inherit;">":/"</span><span style="margin:0px;padding:0px;border:none;background-color:inherit;">10/</span><span class="string" style="margin:0px;padding:0px;border:none;color:red;background-color:inherit;">"},{/"</span><span style="margin:0px;padding:0px;border:none;background-color:inherit;">text/</span><span class="string" style="margin:0px;padding:0px;border:none;color:red;background-color:inherit;">":/"</span><span style="margin:0px;padding:0px;border:none;background-color:inherit;">邵家湾/</span><span class="string" style="margin:0px;padding:0px;border:none;color:red;background-color:inherit;">",/"</span><span style="margin:0px;padding:0px;border:none;background-color:inherit;">value/</span><span class="string" style="margin:0px;padding:0px;border:none;color:red;background-color:inherit;">":/"</span><span style="margin:0px;padding:0px;border:none;background-color:inherit;">13/</span><span class="string" style="margin:0px;padding:0px;border:none;color:red;background-color:inherit;">"}]"</span><span style="margin:0px;padding:0px;border:none;background-color:inherit;">} </span></span> </li> <li class="" style="margin:0px !important;padding:0px 3px 0px 10px !important;border-style:none none none solid;border-left-width:3px;border-left-color:#999999;list-style:decimal-leading-zero outside;color:#555555;line-height:18px;background-color:#F5FAE2;"> <span style="margin:0px;padding:0px;border:none;color:black;background-color:inherit;"> json = eval(json.options) </span> </li> <li class="alt" style="margin:0px !important;padding:0px 3px 0px 10px !important;border-style:none none none solid;border-left-width:3px;border-left-color:#999999;list-style:decimal-leading-zero outside;color:inherit;line-height:18px;background-color:#F5FAE2;"> <span style="margin:0px;padding:0px;border:none;color:black;background-color:inherit;"> <span class="keyword" style="margin:0px;padding:0px;border:none;color:blue;font-weight:bold;background-color:inherit;">for</span><span style="margin:0px;padding:0px;border:none;background-color:inherit;">(</span><span class="keyword" style="margin:0px;padding:0px;border:none;color:blue;font-weight:bold;background-color:inherit;">var</span><span style="margin:0px;padding:0px;border:none;background-color:inherit;"> i=0; i<json.length; i++) </span></span> </li> <li class="" style="margin:0px !important;padding:0px 3px 0px 10px !important;border-style:none none none solid;border-left-width:3px;border-left-color:#999999;list-style:decimal-leading-zero outside;color:#555555;line-height:18px;background-color:#F5FAE2;"> <span style="margin:0px;padding:0px;border:none;color:black;background-color:inherit;"> { </span> </li> <li class="alt" style="margin:0px !important;padding:0px 3px 0px 10px !important;border-style:none none none solid;border-left-width:3px;border-left-color:#999999;list-style:decimal-leading-zero outside;color:inherit;line-height:18px;background-color:#F5FAE2;"> <span style="margin:0px;padding:0px;border:none;color:black;background-color:inherit;"> alert(json[i].text+<span class="string" style="margin:0px;padding:0px;border:none;color:red;background-color:inherit;">" "</span><span style="margin:0px;padding:0px;border:none;background-color:inherit;"> + json[i].value) </span></span> </li> <li class="" style="margin:0px !important;padding:0px 3px 0px 10px !important;border-style:none none none solid;border-left-width:3px;border-left-color:#999999;list-style:decimal-leading-zero outside;color:#555555;line-height:18px;background-color:#F5FAE2;"> <span style="margin:0px;padding:0px;border:none;color:black;background-color:inherit;"> } </span> </li> <li class="alt" style="margin:0px !important;padding:0px 3px 0px 10px !important;border-style:none none none solid;border-left-width:3px;border-left-color:#999999;list-style:decimal-leading-zero outside;color:inherit;line-height:18px;background-color:#F5FAE2;"> <span style="margin:0px;padding:0px;border:none;color:black;background-color:inherit;">} </span> </li> <li class="" style="margin:0px !important;padding:0px 3px 0px 10px !important;border-style:none none none solid;border-left-width:3px;border-left-color:#999999;list-style:decimal-leading-zero outside;color:#555555;line-height:18px;background-color:#F5FAE2;"> <span style="margin:0px;padding:0px;border:none;color:black;background-color:inherit;"></script> </span> </li> </ol> </p> <div> </div> 最后修改:1970 年 01 月 01 日 © 允许规范转载 打赏 赞赏作者 赞 如果觉得我的文章对你有用,请随意赞赏