JS - 查找字符串中的某个值,截取其之前。和之后的值

var str = "11:222";    

/*

*   截取 “ :”之前和之后的值  

*/
document.write(str.split(':')[0])    //输出11
document.write(str.split(':')[1])    //输出222

猜你喜欢

转载自www.cnblogs.com/500m/p/11429422.html