js 字符串变二维数组
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 2 <html xmlns="http://www.w3.org/1999/xhtml"> 3 <head> 4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 5 <title></title> 6 <script src="scripts/jquery-1.3.1.js" type="text/javascript"></script> 7 <script type="text/javascript"> 8 $(function() { 9 var strq = "1;a;11|3;c;33|5;e;55|4;d;44|2;b;22"; 10 var str = new Array(); 11 var arr = new Array(); 12 str = strq.split("|"); 13 var htmlstr = ""; 14 for(i=0;i<str.length;i++){ 15 var str_c = new Array(); 16 arr[i] = new Array(); 17 str_c = str[i].split(";"); 18 for(j=0;j<str_c.length;j++){ 19 arr[i][j] = str_c[j]; 20 } 21 } 22 for(i=0;i<5;i++){ 23 for(j=0;j<3;j++){ 24 htmlstr = htmlstr + arr[i][j]; 25 } 26 } 27 28 $('div').html(htmlstr); 29 }); 30 </script> 31 <style type="text/css"> 32 <!-- 33 #apDiv1 { 34 position:absolute; 35 left:481px; 36 top:36px; 37 width:172px; 38 height:202px; 39 z-index:1; 40 } 41 --> 42 </style> 43 </head> 44 <body> 45 <div id="apDiv1"></div> 46 </body> 47 </html>