안녕하세요이 의사 코드가 있습니다통합 jQuery를 쿠키
if(cookie set){
$("#notification").hide();
}
else {
$("#notification").show();
}
어떻게 내가 jQuery를 쿠키 플러그인을 통합 할 수 있습니다를, 그래서 그 다음 쿠키를 발견 한 경우는 #notification 저작권을 보여 나던?
감사를 제공
안녕하세요이 의사 코드가 있습니다통합 jQuery를 쿠키
if(cookie set){
$("#notification").hide();
}
else {
$("#notification").show();
}
어떻게 내가 jQuery를 쿠키 플러그인을 통합 할 수 있습니다를, 그래서 그 다음 쿠키를 발견 한 경우는 #notification 저작권을 보여 나던?
감사를 제공
if ($.cookie('whatever')) {
//exists
} else {
//nuthin!
}
사용 : http://plugins.jquery.com/project/Cookie
당신은 또한 할 수있는 [편집] :
if ($.cookie('whatever') !== null) {
//exists
} else {
//still nuthin
}
가정이 this 플러그인 사용
if ($.cookie('the_cookie')) DO_YOUR_WORK;
을
이 코드이 나를 위해 일한 :
<script>
if ($.cookie('whatever')) {
alert('exists');
} else {
alert('not exists');
}
//$.cookie('whatever', 'asd'); writing cookie..
</script>
쿠키가 클라이언트 측 환경에 데이터를 저장하는 가장 중요한 것은 나 기술입니다. jQuery Cookie는 클라이언트 측에서 쿠키를 읽고, 읽고 삭제할 수있는 간단하고 가벼운 플러그인입니다.
처음에는 jquery.cookie 플러그인을 다운로드하고 페이지에 추가하기 만하면됩니다.
<head>
<script src="js/jquery.js"></script>
<script src="js/jquery.cookie.js"></script>
</head>
설정 쿠키 :
$.cookie('cookie_name', 'cookie_value', { expires: 7 });
받기 쿠키 :
$.cookie('cookie_name');
삭제 쿠키 :
$.cookie('cookie_name', null, { path: '/' });