我有另一个问题:

document.getElementById('value').innerHTML=listCookies()
function listCookies() {
    var theCookies = document.cookie.split(';');
    var aString = '';
    for (var i = 1 ; i <= theCookies.length; i++) {
        aString += ' ' + theCookies[i-1] + "\n";
    }
    return aString;
}


它会说:

cookie=value


我该怎么做:

cookie with the value 4

最佳答案

function listCookies() {
    var theCookies = document.cookie.split(';');
    var aString = '';
    for (var i = 0 ; i < theCookies.length; i++) {
        aString += ' ' + theCookies[i].replace('=', ' with the value ') + "\n";
    }
    return aString;
}

10-06 02:42