日期:2014-05-16 浏览次数:20365 次
<ul id="level"> <li>0</li> <li>0</li> <li>0</li> <li>0</li> </ul> <script type="text/javascript"> window.onload=function(){ function setCookie(cookieName,cookieValue,cookieDate){ //cookieValue=escape(cookieValue); var nowDate=new Date(); nowDate.setMonth(nowDate.getMonth()+9); cookieDate=nowDate.toGMTString(); document.cookie=cookieName+'='+cookieValue+';expires='+cookieDate; } //setCookie('值','0000','9'); function getCookie(cookiename){ var strCookie=document.cookie; var srtArray=strCookie.split('='); var cookieValue=srtArray[1]; return cookieValue; } function setValue(){ var element=document.getElementById('level'); var tags=element.getElementsByTagName('li'); var i=0; var valueArray=[]; if(valueArray!=''){ valueArray=getCookie('值=').split(''); for(i=0; i<tags.length; i++){ tags[i].index=i; tags[i].innerHTML=valueArray[i]; } }else{ //return null; } } setValue(); function onSetValue(){ var element=document.getElementById('level'); var tags=element.getElementsByTagName('li'); var i=0; var j=0; var c=[]; for(i=0; i<tags.length; i++){ tags[i].index=i; tags[i].onclick=function(){ this.innerHTML=parseInt(this.innerHTML)+1; var arrayValue=setValue('值='); if(arrayValue==undefined){ for(j=0; j<tags.length; j++){ c.push(tags.innerHTML); } } setCookie('值',c.splice(this.index,1,this.innerHTML),'9') }; } } alert(document.cookie); onSetValue(); } </script>
function et_cookie_set(name,value,expires,path,domain){ var today = new Date(); if (expires){ expires = expires * 1000; } var expires_date = new Date( today.getTime() + (expires) ); document.cookie = name + '=' +escape( value ) + ( ( expires ) ? ';expires=' + expires_date.toGMTString() : '' ) + ( ( path ) ? ';path=' + path : '' ) + ( ( domain ) ? ';domain=' + domain : '' ); } function et_cookie_get(name){ var cookieValue = "