JSFiddle - React, Tailwind, and code Playground

by hjjunior

HTML

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-maskmoney/3.0.2/jquery.maskMoney.min.js"></script>
<input type="text" id="currency" data-thousands="." data-decimal="," />
<button>
Set value
</button>

JavaScript

let elementCurrency = $('#currency').maskMoney();

// elementCurrency.maskMoney();

applyNewValue(elementCurrency, 0.1)


$("button").click(function() {
	applyNewValue(elementCurrency, 50.1)
})

function applyNewValue(element, newValue) {
	element.maskMoney('mask', newValue)
}