function div catalog ul li parent div label on click function event va

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
$(function() {
$('div.catalog > ul > li.parent > div.label').on('click', function (event) {
var parent = $(this).parent();
if (parent.hasClass('active')) {
disableTree(parent);
} else {
activeTree(parent);
}
return false;
});
});
function activeTree(parent) {
var trees = $('div.catalog > ul > li.parent');
trees.each(function(index) {
disableTree(trees.eq(index));
});
parent.children('div.label').html('-');
parent.children('a').addClass('active');
parent.children('ul.active').show(150);
parent.addClass('active');
return true;
}
function disableTree(parent) {
parent.children('div.label').html('+');
parent.children('a').removeClass('active');
parent.children('ul.active').hide(150);
parent.removeClass('active');
return true;
}