1.字符串转为字符串数组:split函数
<% String price = "496.0 398.0 269.0 "; %> <script type="text/javascript"> var pr = "<%=price%>"; alert(pr); var pri = pr.split(" "); alert(pri); </script>
2.遍历数组
for(var i = 0;i<pri.length;i++){ alert(pri[i]); }
1.字符串转为字符串数组:split函数
<% String price = "496.0 398.0 269.0 "; %> <script type="text/javascript"> var pr = "<%=price%>"; alert(pr); var pri = pr.split(" "); alert(pri); </script>
2.遍历数组
for(var i = 0;i<pri.length;i++){ alert(pri[i]); }