$(function () { $('.tree li:has(ul)').addClass('parent_li').find(' > span').attr('title', 'Collapse this branch'); $('.tree li.parent_li > span').on('click', function (e) { var children = $(this).parent('li.parent_li').find(' > ul > li'); if (children.is(":visible")) { children.hide('fast'); $(this).attr('title', 'Expand this branch').find(' > i').addClass('fa-plus-square').removeClass('fa-minus-square'); } else { children.show('fast'); $(this).attr('title', 'Collapse this branch').find(' > i').addClass('fa-minus-square').removeClass('fa-plus-square'); } e.stopPropagation(); }); $('.tree .shape').on('click', function (e) { $('.infoBlk').hide(); $('.infoBlk#' + $(this).attr('id') + 'Info').show(); e.stopPropagation(); }); });