我只想知道如何在此javascript代碼開關上添加淡入淡出效果。如何在此javascript上添加淡入淡出效果
//<![CDATA[
function toggleList(id, displayValue) {
var obj = document.getElementById(id);
if(!displayValue)
{
var displayValue = (obj.style.display!='none')?'none':'block';
}
obj.style.display = displayValue;
setCookie(id, displayValue, 30);
return;
}
window.onload = function()
{
toggleList('sidebar_block_content', getCookie('sidebar_block_content'));
return;
}
function setCookie(name, value, expiredays)
{
if (expiredays==null) { expiredays=0; }
var expireDate = new Date();
expireDate.setDate(expireDate.getDate()+expiredays);
var cookieVal = name + '=' +escape(value) + ';expires=' + expireDate.toGMTString();
document.cookie = cookieVal;
return;
}
function getCookie(searchName)
{
if (document.cookie.length>0)
{
var nameValuePair, cookieName, cookieValue
var pairs = document.cookie.split(';');
for(var i=0; i<pairs.length; i++)
{
nameValuePair = pairs[i].split('=');
cookieName = nameValuePair[0].replace(/^\s+|\s+$/g,'');
cookieValue = nameValuePair[1].replace(/^\s+|\s+$/g,'');
if(cookieName == searchName) { return cookieValue; }
}
}
return false;
}
//]]>
此代碼適用於cookie,我想添加淡入淡出效果(如jquery效果)來使用切換。任何人都可以幫助我嗎? :) 謝謝!
對不起,但你的第一個代碼不工作..我只需要修改我的代碼與淡出效果... –
更新與小提琴... – joaumg
是的,這是好的,但我希望這與我的代碼完成(我因爲當我點擊我的觸發按鈕時,我想切換我的元素... –