2014-07-06 62 views
1

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

var aside未定義。應該在引號中使其成爲一個字符串

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