user995691 user995691 - 9 months ago 141
Javascript Question

JQuery toFixed is not a function

I have this JavaScript code:

if($('#numlic').val() <= 10) {
$('#totalprice').text(23.10 * $('#numlic').val()).toFixed(2);

but it doesn't work and I get the "toFixed is not a function" error.
Can you help me with this?
Thanks in advance.


It's a simple typo:

if($('#numlic').val() <= 10) {
    $('#totalprice').text((23.10 * $('#numlic').val()).toFixed(2));

The toFixed function is an extension of a Number. You're trying to set the element $('#totalprice') .toFixed(2), when you want to set the result of "23.10 * $('#numlic').val()".