本文實例講述了js字符串操作方法。分享給大家供大家參考。具體如下:
var str="This is my first Script code.";document.write("原字符串為:"+str+"<br>")document.write("第五個字符之后的部分:"+str.slice(5,-1)+"<br>");document.write("第五個字符之后的15個字符:"+str.substr(5,15)+"<br>");document.write("第五個字符后至第15個字符:"+str.substring(5,15)+"<br>");
希望本文所述對大家的javascript程序設計有所幫助。
新聞熱點
疑難解答