The following jQuery code works if my tag is:
<input class="AmountElementValue" readonly="readonly" />
However, it does not work if I make the input a <div />
. The code is:
$(".AmountElementValue").each(function () {
alert($(".AmountElementValue").val());
var TrimedAmountElementValu开发者_高级运维e = $(this).val().replace(/\$/g, '');
TrimedAmountElementValue = TrimedAmountElementValue.replace(",", "");
totalDisbursement += parseFloat(TrimedAmountElementValue);
});
How can use a <div />
instead?
.val()
does not work on <div />
s; perhaps you want .text()
or .html()
?
.val()
is only defined for input elements. Use .text()
instead for a div.
精彩评论