I want to add a class to an li element which is sub element of an li.
<div id="test" class="list">
<ul>
<li><a id="Inbox">Inbox</a>
<ul></ul>
</li>
<li><a id="Sent">Sent</a>
<ul></ul>
</li>
<li><a id="Archive">Archive</a>
<ul></ul>
</li>
<li><a id="Deleted">Deleted</a>
<ul>
<li><a id="Subfolder1">Sub Folder 1</a></li>
</ul>
</li>
</ul>
</div>
Mouse enter and Mouse leave functions:
$('#test li').each(function(){
$(this).on("mouseenter",function(){
$(this).addClass("enter-folder");
});
$(this).on("mouseleave",function(){
$(this).removeClass("enter-folder");
});
});
When mouse is on subfolder1 the class is adding to subfolder1 li elemnt as well as the parent li element which has text deleted.
Fiddle: http://jsfiddle.net/UVJgF/36/
I just want to add class to subfolder1 when mouse is on subfolder1.
How to fix this issue.