天天看点

jQuery实现网站皮肤的设置

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />

<title>????棰???妗?lt;/title>

<script src="jquery-1.4.2.js" type="text/javascript"></script> ? ? ?~~~~娉ㄦ??jquery-1.4.2.js??jquery.cookie.js涓や釜??浠剁??璺?寰?

<script src="jquery.cookie.js" type="text/javascript"></script>

<script type="text/javascript">

$(function(){

$("#1 td").click(function(){

var bg=$(this).css("background-color");

$("body").css("background-color",bg);

$.cookie("back",bg,{expires:10}); //?峰??璁剧疆?????や?瀛???ookie涓?锛?灏??????堕?磋?剧疆涓?0澶?

}).css("cursor","pointer");//????灏???褰㈢??

var bgColor=$.cookie("back");

if(bgColor)//濡???涓?涓虹┖锛?body?????ゅ氨涓哄???????璁剧疆??????

{

$("body").css("background-color",bgColor);

}

});

</script>

</head>

<body>

<table id="1">

<tr>

<td style="background-color:#00FF99"width="100px" height="50px"></td>

<td style="background-color:#FF33CC"width="100" height="50"></td>

<td style="background-color:#33FFFF"width="100px" height="50px"></td>

</tr>

</table>

</body>

</html>

继续阅读