ã¯ããã«
ãã®ã¨ã³ããªã§ã¯JavaScriptã§cookieã®ãã¼ã¿ãèªã¿æ¸ãããæ¹æ³ã«ã¤ãã¦æ¸ãã¦ãã¾ããjQueryã使ããã«JavaScriptã ãã§cookieãæä½ãããã¨ã¯ã§ãã¾ãããjQueryã使ãã¨ã¨ã¦ãç°¡åã«å®è£
ãããã¨ãã§ãã¾ãã
ãã®ã¨ã³ããªãæ¸ãã«ãããã以ä¸ã®ãµã¤ããåèã«ãã¾ããã
- jQueryã¨jquery.cookie.jsã使ã£ã¦ééãä¿æããã¡ãã¥ã¼ãä½ã£ã¦ã¿ãï½caraldo.net | Webã¨iPhoneã¨ãã¼ããã¤ã¯ã大好ãï¼
ã¤ã³ãã¬ã¹ã¸ã£ãã³
売ãä¸ãã©ã³ãã³ã°: 18792
JavaScriptã«ããcookieã®æä½
JavaScriptã ãã§cookieãæä½ããå ´åã以ä¸ã®ããã«ãã¾ãã
// cookieã«ãã¼ã¿ãã»ãã document.cookie = "KEY=VALUE"; // cookieãããã¼ã¿ãåå¾ var hoge = document.cookie;
document.cookieã®å¤ãåå¾ããã¨åããã¾ãããcookieã«æ ¼ç´ããæååããã¹ã¦åå¾ããã¦ãã¾ãã¾ããç¹å®ã®ãã¼ã«å¯¾å¿ããå¤ãåå¾ããæ¨æºé¢æ°ããªãã®ã§ã以ä¸ã®ãµã¤ãã®ããã«ãã¼ããå¤ãåãåºããããªå®è£ ãããå¿ è¦ãããã¾ãã
cookieãç°¡åã«æ±ããããã«ããjquery.cookie.js
ãã¼ããå¤ãåå¾ããã¡ãã£ã¨é¢åãªå¦çãã¨ã¦ãç°¡åã«ã§ããããã«ãã¦ãããã®ãjQueryã®ãã©ã°ã¤ã³jquery.cookie.jsã§ãã
jquery.cookie.jsã®ä½¿ãæ¹
ã¯ããã«ãjQueryã¨jquery.cookie.jsãèªã¿è¾¼ã¾ãã¾ãã
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.0/jquery.min.js"></script> <script type="text/javascript" src="jquery.cookie.js"></script>
jquery.cookie.jsã§cookieãæä½ããã«ã¯ã以ä¸ã®ããã«ãã¾ãã
// cookieã«ãã¼ã¿ãã»ãã $.cookie('KEY', 'VALUE'); // KEYã«å¯¾å¿ããå¤ãåå¾ var hoge = $.cookie('KEY');
expiresã§cookieã®æå¹æéãæå®ãããã¨ãã§ãã¾ãã以ä¸ã®ã³ã¼ãã®å ´åã¯7æ¥éæå¹ã«ãªãã¾ãã
$.cookie('KEY', 'VALUE', { expires: 7 });
é¢é£ã¨ã³ããª
- jQueryã°ã©ãæç»ã©ã¤ãã©ãªjqplotã§æ£ã°ã©ããæã
- jQueryã°ã©ãæç»ã©ã¤ãã©ãªjqplotã§æãç·ã°ã©ããæã
- jQueryã§ã¢ã¼ãã«ãã¤ã¢ãã°ãå®ç¾ããAvgrund Modal
- ããã¹ãå ã®URLãæ¢ãã¦ãªã³ã¯ãè²¼ã£ã¦ãããjquery.autolink
- jQueryã§window.onloadãæ¸ãæ¹æ³