Hi I have the following code
<ul id="sample-menu-1" class="sf-menu">
<li class="current"><a href="#a">main item <span class="cntnews">0</span></a>
<ul>
<li><a href="#ab">sub item 1 <span class="cntnews">0</span></a>
<ul>
<li><a href="#">menu item <span class="cntnews">4</span></a></li>
<li><a href="#aba">menu item <span class="cntnews">8</span></a></li>
<li><a href="#"> sub item 2<span class="cntnews">0</span></a>
<ul>
<li><a href="#">menu item <span class="cntnews">6</span></a></li>
<li><a href="#">menu item <span class="cntnews">8</span></a></li>
</ul>
</li>
</ul>
</li>
</ul>
What I would like to do in my jQuery script is have the <span class="cntnews">0</a> have the sum of these items of there descendants
so for mainitem this will be 26, for sub item 1 this will be 26, and for subitem 2 this will be 14
I would like this to work for any unordered list. So far im not getting the result I want so any help would be appreciated
I would do it like this: