詳解easyui 切換主題皮膚
jquery cookie下載地址::http://plugins.jquery.com/cookie/
1.需要導(dǎo)入的文件(我這里的easyui是jquery-easyui-1.6.11版本)
主要實(shí)現(xiàn)原理就是換導(dǎo)入css文件,這樣就可以實(shí)現(xiàn)切換主題皮膚
<!-- 引入easyui css樣式 只需引入easyui.css 其中就包含了其他的內(nèi)容--> <link rel="stylesheet" id="easyuiTheme" href="<%=request.getContextPath()%>/jquery-easyui-1.6.11/themes/default/easyui.css" rel="external nofollow" > <!-- 引入小圖標(biāo) --> <link rel="stylesheet" href="<%=request.getContextPath()%>/jquery-easyui-1.6.11/themes/icon.css" rel="external nofollow" > <!-- 引入jQuery --> <script type="text/javascript" src="<%=request.getContextPath()%>/js/jquery-1.11.3.js"></script> <script src="js/jquery.cookie.js"></script> <!-- 引入easyui --> <script src="<%=request.getContextPath()%>/jquery-easyui-1.6.11/jquery.easyui.min.js" ></script> <!-- 樣式轉(zhuǎn)化為中文 --> <script src="<%=request.getContextPath()%>/jquery-easyui-1.6.11/locale/easyui-lang-zh_CN.js"></script>
2.前臺頁面定義了一個按鈕(代碼)
<div style="position: absolute;right: 14px;top:42px;">
<div style="padding:5px;">
<a href="javascript:void(0);" rel="external nofollow" class="easyui-menubutton" data-options="menu:'#layout_north_pfMenu',iconCls:'icon-ok'">更換皮膚</a>
</div>
</div>
<div id="layout_north_pfMenu" style=" display: none;">
<div "changeTheme('default');">default</div>
<div "changeTheme('black');">black</div>
<div "changeTheme('bootstrap');">bootstrap</div>
<div "changeTheme('gray');">gray</div>
<div "changeTheme('metro');">metro</div>
</div>
3.前臺效果圖

4.< script>里邊寫了這個方法:changeTheme
/**
* 更換EasyUI主題的方法
* @param themeName
* 主題名稱
*/
changeTheme = function(themeName) {
var $easyuiTheme = $('#easyuiTheme');
var url = $easyuiTheme.attr('href');
var href = url.substring(0, url.indexOf('themes')) + 'themes/' + themeName + '/easyui.css';
$easyuiTheme.attr('href', href);
var $iframe = $('iframe');
if ($iframe.length > 0) {
for ( var i = 0; i < $iframe.length; i++) {
var ifr = $iframe[i];
$(ifr).contents().find('#easyuiTheme').attr('href', href);
}
}
$.cookie('easyuiThemeName', themeName, {
expires : 7
});
};
5.效果

切換之后效果,我就不一一展示效果了

以上所述是小編給大家介紹的easyui 切換主題皮膚方法詳解整合,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復(fù)大家的。在此也非常感謝大家對腳本之家網(wǎng)站的支持!
相關(guān)文章
PHP+jquery+ajax實(shí)現(xiàn)分頁
這篇文章主要為大家詳細(xì)介紹了PHPjquery+ajax實(shí)現(xiàn)分頁的代碼,具有一定的參考價值,感興趣的小伙伴們可以參考一下2016-12-12
jQuery實(shí)現(xiàn)轉(zhuǎn)動隨機(jī)數(shù)抽獎效果的方法
這篇文章主要介紹了jQuery實(shí)現(xiàn)轉(zhuǎn)動隨機(jī)數(shù)抽獎效果的方法,涉及jQuery操作隨機(jī)數(shù)及頁面元素的相關(guān)技巧,需要的朋友可以參考下2015-05-05
jquery 1.3.2 IE8中的一點(diǎn)點(diǎn)的小問題解決方法
最近的項(xiàng)目中開始使用了新版本的jquery,就是1.3.2版,發(fā)現(xiàn)在這個在版本對就radio類型的input在IE8中的支持不太好2009-07-07
jquery 學(xué)習(xí)之二 屬性相關(guān)
jquery 學(xué)習(xí)之二 屬性相關(guān)資料,學(xué)習(xí)jquery的朋友可以參考下。2010-11-11
jquery實(shí)現(xiàn)metro效果示例代碼
metro效果想必大家并不陌生吧,下面為大家講解下在jquery中時如何實(shí)現(xiàn)的,新手朋友們可不要錯過了2013-09-09
ASP.NET中使用后端代碼注冊腳本 生成JQUERY-EASYUI的界面錯位的解決方法
上一篇解決了用了JQUERY-EASYUI時 后端注冊腳本重復(fù)執(zhí)行的問題.今天又發(fā)現(xiàn),通過后端代碼 生成的界面有錯位現(xiàn)象.2010-06-06
jQuery實(shí)現(xiàn)判斷控件是否顯示的方法
這篇文章主要介紹了jQuery實(shí)現(xiàn)判斷控件是否顯示的方法,涉及jQuery針對頁面元素屬性相關(guān)操作技巧,需要的朋友可以參考下2017-01-01

