开发者

I need $(".className").each(function () with div. I can only get it to work with input

开发者 https://www.devze.com 2023-02-08 23:18 出处:网络
The following jQuery code works if my tag is: <input class=\"AmountElementValue\" readonly=\"readonly\" />

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消