Need a little help…
The following adds a converted currency label after an input for a numeric value – works fine when I press keyup (I can see the coverted label):
$(document).ready(function(){
$("input.currency-field").each(function () {
$(this).after("<label class='currency'></label>");
});
$("input.currency-field").bind("keyup", function () {
$(this).siblings('label.currency').text($(this).val());
$(this).siblings('label.currency').formatCurrency();
});
});
I’d like to have the converted values load when the page loads, rather than waiting to press keyup. I’ve tried to call the keyup event after adding the label in the .each function, but I can’t seem to get it to work (also tried calling $(“input.currency-field”).keyup() outside the function;
It would be best to wrap it all in a function then use this for both the bind and on document ready (or where ever else you want to use it), however you can use trigger for what you are trying to do:
This should trigger the keyup event providing it has been set.