Reputation: 3457
The above is the HTML
<section id="topping_tsection_57">
<i id="topping-close"></i>
<aside>
<h6 class="tdHeading">Quantity1</h6>
<img src="images/arrow-topping.png">
<section class="secclass"><a data-id="57" class="tpActive">Honey with Chocolate Sauce 10 ML</a></section>
<section class="secclass"><a data-id="57">Honey with Carmel 10 ML</a></section>
<section class="secclass"><a data-id="57">Strawberry</a></section>
</aside>
<aside>
<h6 class="tdHeading">Quantity2</h6>
<img src="images/arrow-topping.png">
<section class="secclass"><a data-id="57" class="tpActive">Honey with Chocolate Sauce 10 ML</a></section>
<section class="secclass"><a data-id="57">Honey with Carmel 10 ML</a></section>
<section class="secclass"><a data-id="57">Strawberry</a></section>
</aside>
</section>
How to get the total number of aside present under topping_tsection_57
I tried to use the length Or size , but i was getting Uncaught ReferenceError: aside is not defined under console .
i tried it this way .
var id = 57
var n = $("#topping_tsection_"+id+ aside).size();
alert(n);
Could anybody please let me know how to resolve this ??
Upvotes: 1
Views: 83
Reputation: 9583
var aside
is undefined. it should be in quotes to make it a string
var n = $("#topping_tsection_"+id+ ' aside').size();
Upvotes: 1