2011-02-08 34 views
0

下面的jQuery代碼工作,如果我的標籤是工作:。

<input class="AmountElementValue" readonly="readonly" /> 

然而,如果我讓輸入<div />不起作用的代碼是:

$(".AmountElementValue").each(function() { 
    alert($(".AmountElementValue").val()); 
    var TrimedAmountElementValue = $(this).val().replace(/\$/g, ''); 
    TrimedAmountElementValue = TrimedAmountElementValue.replace(",", ""); 
    totalDisbursement += parseFloat(TrimedAmountElementValue); 
}); 

如何使用<div />代替

回答

5

.val()不上<div />的工作,也許?你想要.text()還是.html()

+0

這裏就是事實。 – 2011-02-08 02:46:08

1

.val()僅針對輸入元素進行定義。使用.text()代替div。

相關問題