jquery手風(fēng)琴特效插件
手風(fēng)琴效果是項(xiàng)目中使用頻率較高的一種效果,原來(lái)項(xiàng)目一直都在用easyui的,臨近年末,試著自己寫了一個(gè)
css樣式
/* CSS Document */
body {
margin: 0 auto;
padding: 0 auto;
font-size: 9pt;
font-family: 微軟雅黑, 宋體, Arial, Helvetica, Verdana, sans-serif;
}
.accordion {
padding-left: 0px;
}
.accordion li {
border-top: 1px solid #000;
list-style-type: none;
}
.titlemenu {
width: 100%;
height: 30px;
background-color: #F2F2F2;
padding: 5px 0px;
text-align: left;
cursor: pointer;
}
.titlemenu img {
position: relative;
left: 20px;
top: 5px;
}
.titlemenu span {
display: inline-block;
position: relative;
left: 40px;
}
.submenu {
text-align: left;
width: 100%;
padding-left: 0px;
}
.submenu li {
list-style-type: none;
width: 100%;
}
.submenu li img {
position: relative;
left: 20px;
top: 5px;
}
.submenu li a {
position: relative;
left: 40px;
top: 5px;
text-decoration: none;
}
.submenu li span {
display: inline-block;
height: 30px;
padding: 5px 0px;
}
.hover {
background-color: #4A5B79;
}
自定義js
(function ($) {
piano = function () {
_menu ='[{"title":"一級(jí)目錄","img":"images/cog.png","submenu":[{"title":"二級(jí)目錄","img":"images/monitor_window_3d.png"},{"title":"二級(jí)目錄","img":"images/monitor_window_3d.png"},{"title":"二級(jí)目錄","img":"images/monitor_window_3d.png"}]},{"title":"一級(jí)目錄","img":"images/cog.png","submenu":[{"title":"二級(jí)目錄","img":"images/monitor_window_3d.png"},{"title":"二級(jí)目錄","img":"images/monitor_window_3d.png"},{"id":"4","title":"二級(jí)目錄","img":"images/monitor_window_3d.png"}]}]';
return ep = {
init: function (obj) {
_menu = eval('(' + _menu + ')');
var li ="";
$.each(_menu, function (index, element) {
li += '<li><div class="titlemenu"><img src=' + element.img + ' width="16" height="16" alt=""/><span>' + element.title + '</span></div>';
if(element.submenu!=null)
{
li+='<ul class="submenu">';
$.each(element.submenu, function (ind, ele) {
li += '<li><img src=' + ele.img + ' width="16" height="16" alt=""/><span><a href="#">' + ele.title + '</a></span></li>';
});
li+='</ul>';
}
li+='</li>';
});
obj.append(li);
}
}
}
$.fn.accordion = function (options) {
var pia = new piano();
pia.init($(this));
return this.each(function () {
var accs = $(this).children('li');
accs.each(reset);
accs.click(onClick);
var menu_li = $(".submenu").children("li");
menu_li.each(function (index, element) {
$(this).mousemove(function (e) {
$(this).siblings().removeClass("hover");
$(this).find("a").css("color", "#fff");
$(this).siblings().find("a").css("color", "#000");
$(this).addClass("hover");
});
});
});
}
function onClick() {
$(this).siblings('li').find("ul").each(hide);
$(this).find("ul").slideDown('normal');
return false;
}
function hide() {
$(this).slideUp('normal');
}
function reset() {
$(this).find("ul").hide();
}
})(jQuery);
html調(diào)用方式
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>無(wú)標(biāo)題文檔</title>
<script src="jquery-1.8.0.min.js"></script>
<link rel="stylesheet" type="text/css" href="style.css">
<script src="accordion.js"></script>
<script type="text/javascript">
$(function(){
$("#accordion").accordion();
});
</script>
</head>
<body>
<ul id="accordion" class="accordion" style="width:200px;height:500px;">
</ul>
</body>
</html>
顯示效果


以上就是本文的全部?jī)?nèi)容了,希望大家能夠喜歡
- jQuery Easyui使用(一)之可折疊面板的布局手風(fēng)琴菜單
- jQuery實(shí)現(xiàn)的簡(jiǎn)單手風(fēng)琴效果示例
- jquery插件制作 手風(fēng)琴Panel效果實(shí)現(xiàn)
- jQuery制作效果超棒的手風(fēng)琴折疊菜單
- 基于Jquery代碼實(shí)現(xiàn)手風(fēng)琴菜單
- 基于jquery的slideDown和slideUp做手風(fēng)琴
- jquery實(shí)現(xiàn)手風(fēng)琴效果實(shí)例代碼
- Jquery組件easyUi實(shí)現(xiàn)手風(fēng)琴(折疊面板)示例
- jquery超簡(jiǎn)單實(shí)現(xiàn)手風(fēng)琴效果的方法
- jquery實(shí)現(xiàn)手風(fēng)琴展開效果
相關(guān)文章
基于jQuery實(shí)現(xiàn)返回頂部實(shí)例代碼
這篇文章主要介紹了基于jQuery實(shí)現(xiàn)返回頂部實(shí)例代碼的相關(guān)資料,需要的朋友可以參考下2016-01-01
jQuery實(shí)現(xiàn)的淡入淡出二級(jí)菜單效果代碼
這篇文章主要介紹了jQuery實(shí)現(xiàn)的淡入淡出二級(jí)菜單效果代碼,涉及jQuery中fadeIn及fadeOut的相關(guān)使用技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下2015-09-09
jQuery實(shí)現(xiàn)側(cè)浮窗與中浮窗切換效果的方法
這篇文章主要介紹了jQuery實(shí)現(xiàn)側(cè)浮窗與中浮窗切換效果的方法,涉及jQuery針對(duì)頁(yè)面元素的動(dòng)態(tài)操作技巧,需要的朋友可以參考下2016-09-09
jQuery EasyUI API 中文文檔 - PropertyGrid屬性表格
jQuery EasyUI API 中文文檔 - PropertyGrid屬性表格使用介紹,需要的朋友可以參考下。2011-11-11
easyui 中的datagrid跨頁(yè)勾選問題的實(shí)現(xiàn)方法
很多朋友都遇到這樣的需求,easyui的datagrid分頁(yè)顯示數(shù)據(jù),如果有需求要求勾選多條數(shù)據(jù)且不再同一頁(yè)中,easyui會(huì)保存在其他頁(yè)選中的數(shù)據(jù)嗎?小編結(jié)合資料自己整理了一篇文章,需要的的朋友參考下吧2017-01-01
jQuery綁定事件方法及區(qū)別(bind,click,on,live,one)
這篇文章主要介紹了jq綁定事件方法及區(qū)別,通過五種綁定方式使用bind()進(jìn)行操作,并和one()進(jìn)行區(qū)分,需要的朋友可以參考下2017-08-08

