最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

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。 
然后手寫(xiě)腳本;

復(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)合適的位置。最后手寫(xiě)script激活這個(gè)層:
$('#switcher').themeswitcher();

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

珠海市| 富顺县| 福建省| 交城县| 邵阳市| 开原市| 左云县| 东海县| 普陀区| 万全县| 临夏市| 永吉县| 九龙城区| 平阴县| 中阳县| 沙雅县| 海晏县| 永吉县| 西畴县| 漳浦县| 玉门市| 南江县| 平潭县| 阿勒泰市| 永城市| 禹城市| 克山县| 长宁县| 沽源县| 延津县| 柳河县| 桐梓县| 冀州市| 江山市| 淮阳县| 长岭县| 林州市| 商都县| 石台县| 大英县| 晋宁县|