js 如何去除字符两端的引号

通过js 提供的substring()就可以直接去除引号。(注意是小写,和java不同)

    var imgPath = JSON.stringify(api.pageParam.imgPath);
        alert("1"+imgPath);
        alert("2"+imgPath.length);
        console.log(imgPath);
        alert("3"+imgPath.substring(1,imgPath.length));
        var imgpath = imgPath.substring(1,imgPath.length-1);
        console.log(imgpath);
        document.getElementById("img1").src=imgpath;

你可能感兴趣的:(js)