我从另一个问题得到了这个:
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
答案 0 :(得分:2)
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;
}