<ul class=”accordion-menu” id=”demo-menu”>
<li class=”item-wrapper”>
<a href=”/category1″>Category 1</a>
</li>
<li>
<div class=”item-wrapper”>
<a href=”/category2″>Category 2</a>
</div>
<div class=”ul-wrapper”>
<ul>
<li>
<a href=”/category2/2013-01-16-23-09-22″>Sub category 1</a>
</li>
<li>
<a href=”/category2/2013-01-16-23-09-23″>Sub category 2</a>
</li>
</ul>
</div>
</li>
<li>
<div class=”item-wrapper”>
<a href=”/category3″>Category 3</a>
</div>
<div class=”ul-wrapper”>
<ul>
<li>
<a href=”/category3/2013-01-16-23-09-22″>Sub category 1</a>
</li>
<li>
<a href=”/category3/2013-01-16-23-09-23″>Sub category 2</a></div>
</li>
</ul>
</div>
</li>
<li class=”item-wrapper”>
<a href=”/category4″>Category 4</a>
</li>
</ul>
and 1 piece of javascript handling the click event like this
<script type=”text/javascript”>
$(document).ready( function (){
var acc = document.getElementsByClassName(“item-wrapper”);
var i;
for (i = 0; i < acc.length; i++) {
acc[i].onclick = function(){
this.classList.toggle(“selected”);
this.nextElementSibling.classList.toggle(“show”);
}
}
});
</script>
now I want to add conditions that, clicking the item-wrapper div to show the card, the interest is more behind it must be ul-wrapper div tag, then how? Thanks
html and java script Help
Share
I have checked your code. I am assuming that you need to track the item-wrapper which is clicked and on that bases you need to show the selected items.
You can use use the below code to check the onclick for the item-wrapper.
$(document).ready( function (){
$(’.item-wrapper’).click(function(){
//write your code here
});
});
Please let me know if this is helpful
you still do not know what I mean! you notice the conditions of the card ul – wapper