I'm trying to create / adapt a tree list
, however I'm not able to expand my list by clicking on a label.
List:
<div id="listContainer">
<ul id="expList">
<li style="">
<label style="margin-top: 50px;border-style: solid; border-width: 1px; border-color: #7C7C7C; background-color:#E0E0E0">
Item A
</label>
<ul>
<li>
itens lista A
</li>
</ul>
</li>
</ul>
Starting the error starts from my js function to expand the list:
function prepareList() {
$('#expList').find('li:has(ul)')
.click(function (event) {
if (this == event.target) {
$(this).toggleClass('expanded');
$(this).children('ul').toggle('medium');
}
return false;
})
.addClass('collapsed')
.children('ul').hide();
...
...
}
I have tried to find the label in expList
just to test and I could not solve the question:
$('#expList').find('label')
.click(function (event) {
...
...
}
Follow the complete code: jsfiddle
PS.- If you click outside the list, it expands