gpt4 book ai didi

javascript - 如何将 AutoNumeric 应用于所有选择器?

转载 作者:行者123 更新时间:2023-12-05 04:01:45 25 4
gpt4 key购买 nike

类别: float

在此示例中,AutoNumeric 仅应用于类为 float 的第一个元素输入。

    <script src = "https://unpkg.com/autonumeric" ></script>

<form>
<input type="text" class="form-control cell-in-text float" id="26" asp-for="@Model.ListEtpAnswer.ElementAt(26).Answer" />
<br />
<input type="text" class="form-control cell-in-text float" id="27" asp-for="@Model.ListEtpAnswer.ElementAt(27).Answer" />
<br />
<input type="text" class="form-control cell-in-text float" id="28" asp-for="@Model.ListEtpAnswer.ElementAt(28).Answer" />
<br />


<script>
const autoNumericOptions = {
allowDecimalPadding: "floats",
decimalCharacter: ",",
digitGroupSeparator: "",
//emptyInputBehavior: "zero",
watchExternalChanges: true
};
new AutoNumeric(".float", autoNumericOptions);
</script>

最佳答案

您需要使用 Autonumeric.multiple 一次将其应用于多个元素。

<script src = "https://unpkg.com/autonumeric" ></script>

<form>
<input type="text" class="form-control cell-in-text float" id="26" asp-for="@Model.ListEtpAnswer.ElementAt(26).Answer" />
<br />
<input type="text" class="form-control cell-in-text float" id="27" asp-for="@Model.ListEtpAnswer.ElementAt(27).Answer" />
<br />
<input type="text" class="form-control cell-in-text float" id="28" asp-for="@Model.ListEtpAnswer.ElementAt(28).Answer" />
<br />


<script>
const autoNumericOptions = {
allowDecimalPadding: "floats",
decimalCharacter: ",",
digitGroupSeparator: "",
//emptyInputBehavior: "zero",
watchExternalChanges: true
};
AutoNumeric.multiple(".float",null, autoNumericOptions);
</script>

关于javascript - 如何将 AutoNumeric 应用于所有选择器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55038678/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com