I'm encountering an issue with jQuery where the parent ul li does not open as expected. Below is the structure of my HTML:
<div>
<ul>
<li class="has-sub">
<a href="#">1</a>
<ul>
<li><a href="#">1.1</a></li>
<li><a href="#">1.2</a></li>
<li class="has-sub">
<a href="#">2</a>
<ul>
<li><a href="#">2.1</a></li>
<li><a href="#">2.2</a></li>
<li class="has-sub">
<a href="#">3</a>
<ul>
<li><a href="#">3.1</a></li>
<li><a href="#">3.2</a></li>
More...
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
jQuery:
$(function () {
$('a').each(function () {
if ($(this).prop('href') == window.location.href) {
$(this).addClass('activation');
}
});
});
css:
.open > a:after,
.open > a:before {
-webkit-transform: rotate(45deg);
-moz-transform: rotate(45deg);
-ms-transform: rotate(45deg);
-o-transform: rotate(45deg);
transform: rotate(89deg);}
activation
class is added, but it does not open the parent ul li. I want the parent ul li to open when the class is activated.
How can I achieve this desired solution?