JavaScript基础2
2020-02-24 21:27 默默不语 阅读(184) 评论(0) 编辑 收藏 举报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]); }