如何在第一节内放置计数

时间:2014-07-06 19:31:56

标签: jquery

以上是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>

如何在topping_tsection_57

下获得现有的总数

我尝试使用长度或大小,但我得到未捕获的ReferenceError:在控制台下没有定义

我试过这种方式。

var id = 57
var n = $("#topping_tsection_"+id+ aside).size();
alert(n);

有人可以让我知道如何解决这个问题吗?

1 个答案:

答案 0 :(得分:1)

var aside未定义。它应该在引号中使它成为一个字符串

var n = $("#topping_tsection_"+id+ ' aside').size();