1

I am using maskMoney plugin here. I am trying to apply that mask to a div inner text, however i can't make it work.

     var_value=$("#b_bouquet_originalvalue").text();
     $("#b_bouquet_originalvalue").text($(this).maskMoney('mask',var_value));
     console.log(var_value);

It does not work. any idea?

thanks for the support.

Huangism
  • 16,278
  • 7
  • 48
  • 74
Harold
  • 23
  • 1
  • 6

2 Answers2

2

maskMoney will only work on an <input> element but it doesn't need to be visible.

You can use a hidden moneyMask <input> as a formatter and copy its value to another element (eg div/span) of your choice.

$('#currency').maskMoney({prefix:'$'});//hidden by css directive

function set(val, $container) {
    $('#currency').maskMoney('mask', val);
    $container.text($('#currency').val());
}

DEMO

Roamer-1888
  • 19,138
  • 5
  • 33
  • 44
0

Try this :

$("#b_bouquet_originalvalue").maskMoney('mask',yourValue);
Anarki
  • 373
  • 5
  • 20