请帮助我将jQuery代码转换为Vanilla javascript
$('.currency,.excludeCurrency').each(function () {
new AutoNumeric(this, {
allowDecimalPadding: "floats",
modifyValueOnWheel: false
});
});
答案 0 :(得分:0)
var elements = document.querySelectorAll('.currency, .excludeCurrency');
elements.forEach((item) => {
new AutoNumeric(item, { allowDecimalPadding: "floats", modifyValueOnWheel: false });
});
答案 1 :(得分:0)
比起达米安·佩拉尔塔(Damian Peralta)所使用的,much easier way可以做到这一点:
AutoNumeric.multiple('.currency, .excludeCurrency', {
allowDecimalPadding: 'floats',
modifyValueOnWheel: false,
});