jquery Learning Six

Source: Internet
Author: User

"JQuery Cookie" plugin

A cookie is a content that is stored on a browser, and the user visits the page to
Save the text content in a cookie. The next time you visit the page, you can take it out.
Save the contents of the session. This will get the last "memory" content, the cookie is not jquery
Unique concept, but jquery cookies make it easier for him to use.
Cookies require browser support, and browser cookies can be disabled if the
The cookie is not available. However, it is generally not necessary to consider disabling cookies.
Several characteristics of cookies:
Cookies are related to domain names, so 163.com cannot read baidu.com recorded cookies
Because of this, there is no need to worry about different domain name cookie conflicts when setting cookies:
A domain name can be written to the total size of the cookie is limited, generally thousands of bytes, can write
The total number of cookies is generally dozens of, more than after the browser itself will be based on their own strategy
removing some cookies; The cookie is not written and must be read next time. Browsers may periodically
Will be cleared, the user may also manually clear the
$.cookie ("key value") value
$.cookie ("Key Name", "Key value") Set value
$.cookie ("username", "Tom", {expires:7,domain: ' itcast.cn ', secure:true});
{Expires:8} indicates the ability to save a few days, a recommendation that belongs to the browser

1<! DOCTYPE html>234<script src= "Js/jquery-1.11.1.min.js" ></script>5<script src= "Js/jquery-ui.min.js" ></script>6<script src= "Js/jquery.cookie.js" ></script>7<link href= "Js/jquery-ui.min.css" rel= "stylesheet"/>8<script type= "Text/javascript" >9$(function () {Ten$ ("#dialog"). dialog (); One$ ("#dialog1"). accordion (); A$ ("#dialog2"). tabs (); -         }) -  the</script> - -<body> -<div id= "dialog" > Hello, I am a dialog box! Heihe, I love you </div> +<div id= "Dialog1" > Hello, I am a dialog box! Heihe, I love you </div> -<div id= "Dialog2" > +<ul> A<li><a href= "#tbbase" > Basic Settings </a></li> at<li><a href= "#tbadv" > Advanced Settings </a></li> -</ul> -<ul id= "Tbbase" > -<li><a href= "#" > Username </a></li> -<li><a href= "#" > Refresh rate </a></li> -</ul> in<div id= "Tbadv" > -<label for= "username" > User name: </label><input type= "text" id= "username"/><br/> to<label for= "Password" > Login password: </label><input type= "text" id= "password"/> +</div> -</div> the  *</body> $
1<! DOCTYPE html>234<title>preventdefault () Case </title>5<style type= "Text/css" >6 . qqhead{7font-size:30px;8 Color:deepskyblue;9background-color:red;Ten Cursor:pointer; Onewidth:30%; A         } - . Content { -font-size:20px; the Color:blue; -border-Style:solid; -width:30%; -         } +ul{list-style-Type:none;} -</style> +<!--loading Files-- A<script src= "Js/jquery-1.11.1.min.js" type= "Text/javascript" ></script> at<script src= "Js/jquery.cookie.js" type= "Text/javascript" ></script> -<script src= "Js/jquery-ui.min.js" ></script> -      -<script type= "Text/javascript" > -$(function () { -$ ("#ul1 Li:even"). AddClass ("Qqhead"). Click (function() { $( This). Next ("Li.content"). Toggle (). Siblings ("Li.content"). Hide ()}); in$ ("#ul1 li:odd"). AddClass ("Content"). Click (); -$ ("#ul1 > Li:first"). Click (); to         }) +$(function () { -            //Alert ($.cookie ("username"));//reboot not able to remove the corresponding key value the             //$.cookie ("User name", "Tom"); *             //$.cookie ("username", "Tom", {expires:7,domain: ' itcast.cn ', secure:true}); $ Panax Notoginseng$ ("QQ"). accordion (); -         }) the         +</script> A the<body> +<div id= "QQ" > -<ul id= "UL1" > $<li> My friends </li> $<li> Zhang San <br/> Xiao Wang <br/> Xiao Liu </li> -<li> relatives </li> -<li> Zhang San <br/> Xiao Wang <br/> Xiao Liu </li> the<li> University students </li> -<li> Zhang San <br/> Xiao Wang <br/> Xiao Liu </li>Wuyi<li> Elementary School students </li> the<li> Zhang San <br/> Xiao Wang <br/> Xiao Liu </li> -<li> High School classmates </li> Wu<li> Zhang San <br/> Xiao Wang <br/> Xiao Liu </li> -<li> Strangers </li> About<li> Zhang San <br/> Xiao Wang <br/> Xiao Liu </li> $</ul> -</div> -<table id= "Tablecolor" > -&LT;TR&GT;&LT;TD style= "background-color:red" > Red </td> A&LT;TD style= "Background-color:blue" > Blue </td> +&LT;TD style= "Background-color:yellow" > Yellow </td></tr> the</table> -<script type= "Text/javascript" > $$(function () { the$ ("#tablecolor TD"). Click (function () { the                 varbgcolor = $ ( This). CSS ("Background-color"); the$ ("Body"). CSS ("Background-color"), bgcolor); the$.cookie ("bgcolor", bgcolor,{expires:7}); -             }); in         }) the$ (document). Ready (function() {//the color of the memory window the             if($.cookie ("bgcolor")) About$ ("Body"). CSS ("Background-color", $.cookie ("bgcolor"))); the         }); the   the</script> +</body> -

jquery Learning Six

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.