欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

jquery的Theme和Theme Switcher使用小結(jié)

 更新時(shí)間:2010年09月08日 09:01:44   作者:  
jquery的Theme和Theme Switcher使用總結(jié),學(xué)習(xí)jquery Theme的朋友可以參考下。
首先上一幅截圖,效果不錯(cuò)吧:

一、引入jquery主題theme 
在head中引用jquery主題的CSS鏈接http://ajax.googleapis.com/ajax/libs/jqueryui/1.7/themes/base/jquery-ui.css還有許多其他不同的主題:base, black-tie, blitzer, cupertino, dark-hive, dot-luv, eggplant, excite-bike, flick, hot-sneaks, humanity, le-frog, mint-choc, overcast, pepper-grinder, redmond, smoothness, south-street, start, sunny, swanky-purse, trontastic, ui-darkness, ui-lightness, vader。只要將上面鏈接中的base替換成主題名即可切換不同的主題。 

二、使用jquery主題theme 
給想要裝飾的部分加上class,如:<a class="ui-state-default ui-corner-all" href="#">Nothing's gonna change my love for you</a> 表示默認(rèn)的ui, corner-all表示圓滑四個(gè)角。

 

三、增加hover的效果

這里需要使用jquery的腳本。首先在head中引入jquery庫(kù) 
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script> 
1.3表示1.3里面的最新版本,現(xiàn)在是1.3.2。 
然后手寫腳本;

復(fù)制代碼 代碼如下:

$(function(){$('.ui-state-default').hover(function(){$(this).addClass('ui-state-hover');},function(){$(this).removeClass('ui-state-hover');});});

這樣就實(shí)現(xiàn)了鼠標(biāo)移到上方是改變樣式的效果了。

四、使用Theme Switcher在前臺(tái)更換主題
先引入庫(kù)
復(fù)制代碼 代碼如下:

<script type="text/javascript" src="http://jqueryui.com/themeroller/themeswitchertool/"></script>

,然后可以在頁(yè)面任何地方加入層<div id="switcher">主題切換功能載入中...</div>,我習(xí)慣將這個(gè)switch的wikget做成apDiv層,方便挪動(dòng)合適的位置。最后手寫script激活這個(gè)層:
$('#switcher').themeswitcher();

五、使網(wǎng)頁(yè)記住自己的主題 
每次更換主題,jquery都會(huì)寫入cookie的,要使網(wǎng)頁(yè)記住自己的主題,只需要提取這個(gè)cookie出來(lái),并且刷新頁(yè)面的css即可。 
把腳本寫出來(lái) 

復(fù)制代碼 代碼如下:

$(function(){if(theme==null) updateCSS("http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/themes/base/jquery-ui.css");else updateCSS("http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/themes/"+theme+"/jquery-ui.css");})
function updateCSS(locStr){var cssLink=$('<link href="'+locStr+'"type="text/css" rel="Stylesheet" class="ui-theme"/>');$("head").append(cssLink);if($("link.ui-theme").size()>3){$("link.ui-theme:first").remove();}}

最后頁(yè)面代碼大概是這樣子的:
復(fù)制代碼 代碼如下:

<?xml version="1.0" encoding="UTF-8" ?>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!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=utf-8" />
<style type="text/css">
#switcher {
position:absolute;
left: 564px;
top: 20px;
}
</style>
<script src="http://www.google.com/jsapi"></script>
<script type="text/javascript">google.load("jquery","1.3.2");google.load("jqueryui","1.7.2");function OnLoad(){$('#switcher').html("");var theme=$.cookie('jquery-ui-theme');$(function(){if(theme==null) updateCSS("http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/themes/base/jquery-ui.css");else updateCSS("http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/themes/"+theme+"/jquery-ui.css");});$(function(){$('.ui-state-default').hover(function(){$(this).addClass('ui-state-hover');},function(){$(this).removeClass('ui-state-hover');});});$("#pic2").hide();$('#switcher').themeswitcher();}google.setOnLoadCallback(OnLoad);function updateCSS(locStr){var cssLink=$('<link href="'+locStr+'"type="text/css" rel="Stylesheet" class="ui-theme"/>');$("head").append(cssLink);if($("link.ui-theme").size()>3){$("link.ui-theme:first").remove();}}
</script>
<script type="text/javascript" src="http://jqueryui.com/themeroller/themeswitchertool/"></script>
</script>
<title></title>
</head>
<body>
<div id="switcher">主題切換功能載入中...</div>
<p><a class="ui-state-default ui-corner-all" s gonna change my love for you</a></p>
</body>
</html>

相關(guān)文章

最新評(píng)論