可否设置分割的样式?
var number="13659056283";
document.write(number.split(""));
输出是1,3,6,5,9,0,5,6,2,8,3,
如果我想要变成
1-3-6-5-9-0-5-6-2-8-3
或者136-5905-6283
应该怎么设置参数了?
var number="13659056283";
document.write(number.split(""));
输出是1,3,6,5,9,0,5,6,2,8,3,
如果我想要变成
1-3-6-5-9-0-5-6-2-8-3
或者136-5905-6283
应该怎么设置参数了?
2015-12-20
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>无标题文档</title> <script type="text/javascript"> var num="13659056283"; //var cum=num.substring(0,(num.indexOf("5"))); var cum=num.substring(0,3); //var xum=num.substring((num.indexOf("5")),(num.indexOf("6",num.indexOf("0")))); var xum=num.substring(3,7); //var zum=num.substring((num.indexOf("6",num.indexOf("0")))); var zum=num.substring(7); var zong=[cum,xum,zum] document.write(cum +"<br>"); document.write(xum +"<br>"); document.write( zum+"<br>"); document.write( zong.join("-")+"<br>"); </script> </head> <body> </body> </html>
举报