Harold
Harold

Reputation: 23

How to apply maskmoney on div?

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.

Upvotes: 1

Views: 3279

Answers (2)

Roamer-1888
Roamer-1888

Reputation: 19288

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

Upvotes: 2

Anarki
Anarki

Reputation: 393

Try this :

$("#b_bouquet_originalvalue").maskMoney('mask',yourValue);

Upvotes: 0

Related Questions