I have a question about jQuery , how would the following code Pure JavaScript be using jQuery ?
function writeTotal(value){
var total = document.getElementById('total');
total.innerHTML = floatToMoneyText(value);
}
I have a question about jQuery , how would the following code Pure JavaScript be using jQuery ?
function writeTotal(value){
var total = document.getElementById('total');
total.innerHTML = floatToMoneyText(value);
}
A reduced form:
function writeTotal(value) {
$('#total').html(floatToMoneyText(value));
}
This floatToMoneyText
could probably also be converted to jQuery, but would have to know what you do exactly in it
And how about testing the value parameter to see if it is null / empty:
function writeTotal(value) {
var innerHtml = "";
if (value === window.undefined || value === null || value === "") {
innerHtml = "R$ 0,00";
}
else {
innerHtml = floatToMoneyText(value);
}
$('#total').html(innerHtml);
};