更新了树形菜单功能

This commit is contained in:
Li Jianxuan 2011-12-19 02:34:47 +00:00
parent e7f0e28563
commit 05bc47a5ef
1 changed files with 7 additions and 1 deletions

View File

@ -3,6 +3,7 @@
$.fn.tree = function(options) {
var defualts = {
'class':'.expandable',
'toggle':'.tree-toggle-btn',
'downImg':'/images/plus.gif',
'upImg':'/images/minus.gif'
@ -15,7 +16,12 @@
this.each(function() {
$(this).children('.expandable').each(function (){
$(this).children('.tree-toggle-btn').bind('click', function() {
$(this).parent().children('ul').slideToggle("slow");
$(this).parent().children('ul').slideToggle("slow",function(){
if($(this).css('display')=='none')
$(this).parent(opts.class).find(opts.toggle).find("img").attr('src',opts.downImg);
else
$(this).parent(opts.class).find(opts.toggle).find("img").attr('src',opts.upImg);
});
});
});
});