<div class="aa"></div> <script> //字符串转换为数组 var Str="abc-mng-zhang-mayi"; var newArray=Str.split("-"); $(".aa").text("abc-mng-zhang-mayi 转换 newArray[0]:"+newArray[0]); </script> <div class="bb"></div> <script> //将数组转换为字符串 var newArray2=["abc","mng","zhang","mayi"]; var Str=newArray2.join("-"); $(".bb").text("newArray2 数组转换字符串:"+Str); </script>
时间: 2024-10-24 17:23:27