I have an html contains a div element with list,
<div id='tree'>
<ul>
<li id='1' class='folder expand'>1</li>
<li id='2'>2</li>
<li id='3' >3</li>
<li id='4'>4</li>
</ul>
</div>
I need to find
1.If the li element has class 'folder'?
$('#tree li').live('click',function() {
if($(this).hasClass('folder')){
if($(this).hasClass('expand')){
$(this).removeClass('expand').addClass('cl');
}
else{
$(this).removeClass('cl').addClass('expand');
}
}
}
This code doesn't work. It always go to the else condition.
2.In the above I want to override the class 'expand' with 'collapse'.How to remove only that name matching class??