你好我需要帮助在javascript中设置一个cookie,因为这是我第一次制作一个cookie而且我无法在浏览器中加载cookie。这是我的html和jquery代码
<html>
<head>
</head>
<body>
<table>
<tr>
<th><b class='show' style='cursor:pointer;font-weight: unset;'>Datum</b><b class='hide' style='display:none;cursor:pointer;font-weight: unset;'>Datum</b></th>
<th><b class='show1' style='cursor:pointer;font-weight: unset;'>Zeitfenster</b><b class='hide1' style='display:none;cursor:pointer;font-weight: unset;'>Zeitfenster</b></th>
<th class='orgaunit' style='display:none;'>Betriebstelle</th>
<th class='orgaitem' style='display:none;'>Betriebselemente</th>
<th>Zeit (von - bis)</th>
<th>Pause (von - bis)</th>
<th>Stunden</th>
<th>Details</th>
<th>Bemerkung</th>
</tr>
<tr>
<td> hello</td>
<td style='text-align:left;padding-left:4%;' >hello2</td>
<td class='orgaunit' style= 'display:none;'>hello3 </td>
<td class='orgaitem' style= 'display:none;'>hello4 </td>
<td> hello 5</td>
<td>"hello 6</td>
<td style="padding-right:15px;" >hello 7</td>
<td>hello 8</td>
<td>hello 9</td>
</tr></table>
<script src="2.1.1.js"></script>
<script>
function setCookie(c_name, value, exdays) {
var exdate = new Date();
exdate.setDate(exdate.getDate() + exdays);
var c_value = escape(value) + ((exdays == null) ? "" : "; expires=" + exdate.toUTCString());
document.cookie = c_name + "=" + c_value;
}
function getCookie(c_name) {
var i, x, y, ARRcookies = document.cookie.split(";");
for (i = 0; i < ARRcookies.length; i++) {
x = ARRcookies[i].substr(0, ARRcookies[i].indexOf("="));
y = ARRcookies[i].substr(ARRcookies[i].indexOf("=") + 1);
x = x.replace(/^\s+|\s+$/g, "");
if (x == c_name) {
return unescape(y);
}
}
}
$(document).ready(function(){
var theColumn = $(".show").click(function(){
$(".hide").css({display:"inline-block"});
$(".show").css({display:"none"});
$(".orgaunit").css({display:"table-cell"});
setCookie("selectedColumn", theColumn, 1);
});
//setCookie("selectedColumn", theColumn, 3);
});
$(document).ready(function() {
$(".show").click(function(){
getCookie("selectedColumn");
});
});
$(document).ready(function(){
var theColumn2 = $(".hide").click(function(){
$(".show").css({display:"inline-block"});
$(".hide").css({display:"none"});
$(".orgaunit").css({display:"none"});
});
setCookie("selectedColumn2", theColumn2, 3);
});
$(document).ready(function(){
var theColumn3 = $(".MainContent").ready(function(){
$(".show").css({display:"inline-block"});
$(".hide").css({display:"none"});
$(".orgaunit").css({display:"none"});
});
setCookie("selectedColumn3", theColumn3, 3);
});
$(document).ready(function() {
$(".hide").value = getCookie("selectedColumn");
});
$(".show1").click(function(){
$(".hide1").css({display:"inline-block"});
$(".show1").css({display:"none"});
$(".orgaitem").css({display:"table-cell"});
});
$(".hide1").click(function(){
$(".show1").css({display:"inline-block"});
$(".hide1").css({display:"none"});
$(".orgaitem").css({display:"none"});
});
</script>
</body>
</html>
我已经显示了一个列并再次隐藏它是列Betriebstelle
和列Betriebellement
,在刷新页面之后它又被隐藏了我需要保存保存这些列的条件如果在刷新页面后显示或隐藏它,则与我选择的相同
我所做的cookie是在浏览器中设置的,但我无法将其取回aagin 请帮帮我