此刻,我已將字體大小功能添加到我的Textarea。使用Cookies更改文本區域的字體大小
它工作正常,但現在我想添加餅乾。 這是我走到這一步:
var size=size2 + "px";
var size2=15;
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);}}}
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;}
var cookiesize=getCookie('fontsize');
if(cookiesize!==undefined&&cookiesize!==""&&cookiesize!==null){
size2=cookiesize;
}
else{}
function add(){
size2++;
size=size2+"px";
if(size2 > 40){size2=40;}
setCookie('fontsize',size2,365);
$('#current').html("<b>"+size2+"</b>");
$('#curren').stop(true,true).animate({'top' : '0px'},500);
$('#curren').stop(true,true).delay(3500).animate({'top' : '-50px'},1500);
$('#code1').css('font-size', size2);
}
function less(){
size2--;
size=size2+"px";
if(size2 < 5){size2=5;}
setCookie('fontsize',size2,365);
$('#current').html("<b>"+size2+"</b>");
$('#curren').stop(true,true).animate({'top' : '0px'},500);
$('#curren').stop(true,true).delay(4000).animate({'top' : '-50px'},1500);
$('#code1').css('font-size', size2);
}
$(document).ready(function(){
$('#panel').html("<form method='post' name='pad' align='center'><textarea class='look' rows='11' id='code1' name='text' cols='58'></textarea><br></form>");
$('#current').html("<b>"+size2+"</b>");
$('#curren').stop(true,true).animate({'top' : '0px'},500);
$('#curren').stop(true,true).delay(4000).animate({'top' : '-50px'},1500);
$('#code1').css('font-size', size2);
});
function show(){
$('#curren').stop(true,true).animate({'top' : '0px'},500);
$('#curren').stop(true,true).delay(4000).animate({'top' : '-50px'},1500);
}
我沒有給你們的HTML或CSS,但它不應該是必要的。 現在我所得到的是字體大小數字應該是的未定義消息。
希望你能幫助!
最好的問候,
肖恩
而且,你需要幫助的是什麼問題?有什麼不工作?哪行代碼會出錯? – jfriend00